• 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: NSArray as a static
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSArray as a static (From: Richard Good <email@hidden>)
 >Re: NSArray as a static (From: "Kyle Sluder" <email@hidden>)
 >Re: NSArray as a static (From: Richard Good <email@hidden>)

  • Prev by Date: Re: CGEventTap locks up entire system
  • Next by Date: HFS Path To POSIX Path
  • Previous by thread: Re: NSArray as a static
  • Next by thread: Re: NSArray as a static
  • Index(es):
    • Date
    • Thread