Re: Creating a Class Instance By Name
Re: Creating a Class Instance By Name
- Subject: Re: Creating a Class Instance By Name
- From: Evan Schoenberg <email@hidden>
- Date: Tue, 7 Dec 2004 23:29:13 -0600
You probably want to do something like this:
Class myClassNameClass = NSClassFromString("MyClassName");
myClassNameClass *instance = [[myClassNameClass alloc] init];
-Evan
On Dec 7, 2004, at 11:14 PM, Seth Willits wrote:
I need to create a class instance based on its name (as
NSDocumentController does from the Info.plist in every document-based
application) but I can't figure out the exact steps to do so. I'm
doing:
Class class = objc_getClass("MyClassName");
id instance = class_createInstance(class, 0);
But I always get "warning: initialization makes pointer from integer
without a cast" on the second line.
Reference:
id objc_getClass(const char *aClassName);
id class_createInstance(Class theClass, unsigned additionalByteCount);
-- Seth
_______________________________________________
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
_______________________________________________
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