Re: NSArray as a static
Re: NSArray as a static
- Subject: Re: NSArray as a static
- From: "Shawn Erickson" <email@hidden>
- Date: Mon, 1 Sep 2008 16:34:38 -0700
On Mon, Sep 1, 2008 at 1:47 PM, Richard Good <email@hidden> wrote:
> I'm trying to create an array of string constants to be used inside the
> Person class.
> So let me rephrase the question How do I create an array of constant strings
> such that I have only one instance for the entire class,
> or is that just not possible.
@interface
+ (NSArray*) strings;
@end
@implementation
+ (NSArray*) strings {
static NSArray* strings = nil;
if (strings == nil) {
strings = [[NSArray alloc] init...];
}
return strings;
}
@end
Doing the above hides the static var inside of the method so it
doesn't pollute the file scoped/global name space.
-Shawn
_______________________________________________
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