Re: Null value from NSMutableArray
Re: Null value from NSMutableArray
- Subject: Re: Null value from NSMutableArray
- From: Jens Alfke <email@hidden>
- Date: Mon, 15 Feb 2010 13:24:27 -0800
On Feb 15, 2010, at 1:53 AM, email@hidden wrote:
> RandomObj *fooObj = [[RandomObj alloc]init];
>
> NSEnumerator *enumerator = [fooArray objectEnumerator];
> id obj;
> while ( obj = [enumerator nextObject] ) {
> NSLog( @"%@", obj);
> NSLog( @"%d", fooObj.id);
> NSLog( @"%@", fooObj.name);
> }
I can't really follow what this code is supposed to do. fooObj is a 'blank' object, whose properties don't get set to anything, but you print out its id and name property every time through the loop. Did you mean to use obj instead of fooObj in the last two NSLog calls? In that case, what's fooObj for?
Also, it's a heck of a lot easier to iterate over an array by using
for (id obj in fooArray) { ... }
unless you need your app to remain compatible with the thirty-two Mac users who still run 10.4.
—Jens_______________________________________________
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