I would like to know how to create an object of the specified Class
in objective c. Is there some method I am missing in the runtime docs? If so what is it? I would like to be able to do something like the following:
NSDictionary *types;
-(id<AProtocol>) createInstance:(NSString *) name
{
if ((Class cls = [types objectForKey:name]) != nil)
{
return new Instance of cls;
}
else
{
[NSException raise:@"class not found" format:@"The specified class (%@) was not found.", name];
}
}
please note that name is not a name of the class, but an abbreviation for it, and I cannot do what is indicated in Create object from NSString of class name in Objective-C.