Hello,
Does anyone know how to use a variable of type Class to create an
instance of an object?
I'm writing a method that needs to create an instance of one of two
classes, to be determined at run-time. I want to pass in a Class
variable, and have the method use it to create the instance. I know
this must be possible, because NSMatrix does it. You can setCellClass:
for NSMatrix, and then the cells it creates will be instances of the
class you set. But I can't seem to find documentation about how to
actually create the instance.
In short, I want to do something like this:
Class stringClass = [NSString class];
id myNewString = [[stringClass alloc] init];
But that doesn't work.
Any help would be much appreciated!
Thanks,
Eliza
_______________________________________________
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 [EMAIL PROTECTED]