• 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: Initializing an Array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initializing an Array


  • Subject: Re: Initializing an Array
  • From: Andy <email@hidden>
  • Date: Mon, 21 Jan 2002 22:46:37 -0500

"John C. Randolph" wrote:
>
> On Monday, January 21, 2002, at 02:18 PM, Michael P. Rogers wrote:
>
> > Is it possible to initialize an instance variable array in
> > Objective-C? PB doesn't like it when I attempt to do so in the
> > interface section, i.e., code like this fails:
> >
> > NSString * sayings[2] = {@"Do unto",@"others"};
>
> Try
>
> NSArray *myArray = [[NSArray arrayWithObjects:@"Do
> unto",@"others", nil] retain];
>
> in your +initialize method instead.
>

I found this last night, and its certainly a good replacement for the
similar Java construct. I just wish it were better documented... does
this 'nil' end up in the NSArray after construction, ie is the length of
the above 2 or 3?

(I'm a few hours away from being able to call the code that I'm writing
which uses this, and not knowing is gnawing at me).


--
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside

I think we finally found the killer app for Flash: animated stick men


  • Follow-Ups:
    • Re: Initializing an Array
      • From: "John C. Randolph" <email@hidden>
    • Re: Initializing an Array
      • From: "Erik M. Buck" <email@hidden>
References: 
 >Re: Initializing an Array (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Making a control draw while I'm in a (tightish) loop
  • Next by Date: Re: NSGlyph is still a puzzle
  • Previous by thread: Re: Initializing an Array
  • Next by thread: Re: Initializing an Array
  • Index(es):
    • Date
    • Thread