Fast enumeration
Fast enumeration
- Subject: Fast enumeration
- From: Charlie Dickman <email@hidden>
- Date: Thu, 22 Jul 2010 15:16:14 -0400
In the past I have used the construct
NSEnumerator *_enumerator = [_array objectEnumerator];
id _id = nil;
while (nil != (_id = [_enumerator nextObject])) {
.
.
.
if (condition)
break;
}
if (nil == _id) {
.
.
.
}
to determine if the entire contents of _array had been investigated and, if not, which object in _array met the condition.
When trying to use, instead,
for (id _id in _array) {
}
how, without reverting to effectively using an enumerator as in
id theID = nil;
for (id _id in _array) {
.
.
.
if (condition) {
theID = _id;
break;
}
.
.
.
if (nil != theID) {
.
.
.
}
does one accomplish the same thing?
Charlie Dickman
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden