views:

52

answers:

1

Is there a way in objective-c/Cocoa to alloc an object when the class name isn't know until run-time. I seem to remember something about this a while ago, but can't find anything on it now.

Something like:

[[@"MyClass" alloc] init];

I seem to recall a function that would return some kind of class id based on a string that can then be used to alloc the object.

+10  A: 
id object = [[NSClassFromString(@"MyClass") alloc] init];
Dave DeLong