Let's say I have a method that takes a class, which is called like so:
[registry registerClass:[MyClass class]];
How do I interrogate the class inside -registerClass:
?
-(void) registerClass:(Class)typeClass {
// Verify that instances of typeClass confirm to protocol / respondsToSelector
// ?
// Do stuff
// ...
[myListOfClasses addObject:typeClass];
// ...
}
It's the "?" I'm wondering about. Can I safely (and always) cast Class foo
to NSObject *fooObj
and send it messages, assuming foo will always be a subclass of NSObject? Is there a root metaclass that all NSObject metaclasses inherit from? Or are all Class objects simply instances of a single metaclass?