• 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: Using NSClassFromString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSClassFromString


  • Subject: Re: Using NSClassFromString
  • From: Jonathan Jackel <email@hidden>
  • Date: Fri, 26 Dec 2003 20:43:04 -0500

Objective-C doesn't have class variables. You can wrap static
variables in a class method, though, something like this:

+ (NSArray *)classArray
{
static NSArray *fieldArray = nil;
if(!fieldArray)
{
fieldArray = [[NSArray alloc] initWithObjects:@"one",
@"two",
nil];
}
return fieldArray;
}

which you access by calling [[yourInstance class] classArray] or
[YourClass classArray] or maybe, if you want to make things difficult,
[NSClassFromString(@"YourClass") classArray].

Jonathan


On Dec 26, 2003, at 7:58 AM, Ramakrishna Kondapalli wrote:

> I have created id aNamesClass by using NSClassFromString(@"myClass").
> myClass has a static/class variable and I want to access that through
> aNamesClass. Does anybody know how to do this?
>
>
>
> -------------------------------------------------------
>
> Thanks & Regards,
>
> Ramakrishna,
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Using NSClassFromString (From: "Ramakrishna Kondapalli" <email@hidden>)

  • Prev by Date: Re: IB & Mail.app, Looking for a slider!
  • Next by Date: Re: IB & Mail.app, Looking for a slider!
  • Previous by thread: Using NSClassFromString
  • Next by thread: Re: Using NSClassFromString
  • Index(es):
    • Date
    • Thread