I'm creating an object factory in Obj-C and I really need a selector for a class (static) method. Is it at all possible?
I was thinking about storing a selector to a class method that creates objects of that class. Something like this:
@interface Tank : NSObject
+(id) createObject;
-(void) shoot;
-(void) move;
@end
then have a selector point to the create method: @selector(createObject);
I would then have a NSMutableDictionary with @"Tank" as key and the selector (or a thin wrapper for it) as the object.
The end result would be something like this:
// Add an object type
[GlobalFactory addTypeWithName:@"Tank" selector:@selector(createObject)];
// Create an object
id object = [GlobalFactory create:@"Tank"];