Re: Loading classes for use with NSClassFromString, how?
Re: Loading classes for use with NSClassFromString, how?
- Subject: Re: Loading classes for use with NSClassFromString, how?
- From: Nicko van Someren <email@hidden>
- Date: Mon, 16 May 2005 14:45:56 +0100
On 16 May 2005, at 14:37, Ken Tozier wrote:
I need to convert some stored strings to classes so that I can run one
of their methods. I thought I could use NSClassFromString() like so
[NSClassFromString(@"MyClassName")
doSomethingCool: 5
withThisHereThing: @"bobo"];
But apparently the class isn't loaded yet as NSClassFromString()
always returns nil. Is there a way to load a specific class at
runtime?
Assuming that you are getting the code that implements the necessary
code from some bundle you can use the NSBundle method
-(Class)classNamed:(NSString *)className This will load the bundle's
executable code if it is not already loaded.
Nicko
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden