• 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: How do I create a NSArray of NSString constants?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I create a NSArray of NSString constants?


  • Subject: Re: How do I create a NSArray of NSString constants?
  • From: Todd Yandell <email@hidden>
  • Date: Mon, 27 Jun 2005 11:51:15 -0500

Hi,

The problem it that you're trying to create an NSArray object from something that it not an object (a C array). This is what's generating all of the errors. Instead, you should use the arrayWithObjects: class method to create an initialize an NSArray object. Here's an example:

NSArray *objects = [NSArray arrayWithObjects:@"String1", @"String2", @"String3", nil];

The arrayWithObjects: method is different than most methods in Cocoa in that it takes paremeters separated by a comma rather than by keywords, and that it takes unlimited paramaters. The final paramater, "nil", tells NSArray to stop reading in objects, so it's important to remember to always end the list of arguments passed to arrayWithObjects: with "nil".

Todd Yandell

_______________________________________________
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: 
 >How do I create a NSArray of NSString constants? (From: Scott Mitchell <email@hidden>)

  • Prev by Date: Re: How do I create a NSArray of NSString constants?
  • Next by Date: Re: How do I create a NSArray of NSString constants?
  • Previous by thread: Re: How do I create a NSArray of NSString constants?
  • Next by thread: Re: How do I create a NSArray of NSString constants?
  • Index(es):
    • Date
    • Thread