Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Spike099

macrumors regular
Original poster
Feb 18, 2007
143
0
Canada
So, I was wondering if interrupting the fast enumeration process would pose any memory issues? Basically, I am wondering if the following code follows proper conventions. Where, as soon as a newsItem that has not beed read is found, the method returns YES.

Code:
- (BOOL)hasUnreadNews {
	for ( NewsItem *newsItem in newsItems) {
		if ( ![newsItem hasRead] )
			return YES;
	}
	return NO;
}
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I don't think there's anything wrong with it. I've been using it in my code for years.

BTW fast enumeration is really just a do-while loop in disguise :)
 

Spike099

macrumors regular
Original poster
Feb 18, 2007
143
0
Canada
Yeah it's an NSArray. Alright, the code stays. Thanks guys.

EDIT. Just looking at that documentation page, Apple even uses break many times.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.