• 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: initialize an NSArray with a list of objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: initialize an NSArray with a list of objects


  • Subject: Re: initialize an NSArray with a list of objects
  • From: Andrew Bowman <email@hidden>
  • Date: Tue, 16 May 2006 16:03:18 -0700


On May 16, 2006, at 3:53 PM, David Alter wrote:

Is there a way to initialize an NSArray with a list of strings like I can do in C

Example

the C way
char * myList[] = {"item1", "item2", "item3" }


I tried this, and it only picked up the first item

NSArray * myList = {@"item1", @"item2", @"item3" }

Thanks for the help
-dave


You'll want to use the arrayWithObjects class method, and remember to cap it off with nil. Use like this:

NSArray *myList = [NSArray arrayWithObjects: @"item1", @"item2", @"item3", nil];


- Andrew Bowman _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >initialize an NSArray with a list of objects (From: David Alter <email@hidden>)

  • Prev by Date: Re: initialize an NSArray with a list of objects
  • Next by Date: Re: initialize an NSArray with a list of objects
  • Previous by thread: Re: initialize an NSArray with a list of objects
  • Next by thread: Re: initialize an NSArray with a list of objects
  • Index(es):
    • Date
    • Thread