Re: Using NSClassFromString
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.