Re: NSArray as a static
Re: NSArray as a static
- Subject: Re: NSArray as a static
- From: Richard Good <email@hidden>
- Date: Tue, 2 Sep 2008 08:45:36 -0700
First I do appreciate the help. The code suggested below does what I
need it to, but I don't understand something (probably the semantics
of 'static').
I know the constants are set only once as I traced the code but, it
sure seems like they should be set each time the method is called.
It appears that the line
static NSArray* constants = nil;
is only being executed on the first call to the method and being
ignored on all subsequent calls.
Could someone please explain why? Thanks.
On Sep 1, 2008, at 5:28 PM, Graham Cox wrote:
for example:
+ (NSArray*) myListOfStringConstants
{
static NSArray* constants = nil;
if( constants == nil )
constants = [[NSArray arrayWithObjects:@"constant1",
@"constant2", @"constant3", nil] retain];
return constants;
}
_______________________________________________
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