• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Null value from NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Null value from NSMutableArray
      • From: Matthew Lindfield Seager <email@hidden>
References: 
 >Null value from NSMutableArray (From: "email@hidden" <email@hidden>)

  • Prev by Date: Embedded web server
  • Next by Date: valueForUndefinedKey confusion
  • Previous by thread: Re: Null value from NSMutableArray
  • Next by thread: Re: Null value from NSMutableArray
  • Index(es):
    • Date
    • Thread