NSClassFromString does what you want
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#/
/apple_ref/c/func/NSClassFromString
On Apr 30, 2009, at 3:50 PM, Darren Minifie wrote:
Hi everyone.
I have the situation where I need to dynamically create an object
based on
the value held in a string at runtime. I'm pretty sure the dynamic
nature
of objective-c would allow this, but I cant seem to find the right
method on
NSString or NSObject. I want to do this:
NSString* someClass = @"Dog";
Animal* anAnimal = [[someClass alloc] init];
I know this isn't right, but I'm trying to use the value held in
someClass
as the name of the class I want to instantiate. thanks for the help.
--
Darren Minifie
Graduate Studies: Computer Science
www.myavalon.ca
www.ohsnapmusic.com
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/kentozier%40comcast.net
This email sent to kentoz...@comcast.net
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com