I’ve got a function which creates a few different NSOperation subclasses.
They all use the same parameters the only thing that is different is the Class name.
At the moment I’ve got a function with a repeating block of code running through the function. Is it possible to pass the Class into a function so that the function can create the objects for me?
i.e.
- (void)createOperationSubclass:(Class*)class withParam:(int)parameter
{
class *operation = [[class alloc] init];
operation.parameter = parameter;
[self.queue addOperation:operation];
}
or something like that? i.e. a generic class loader that doesn’t care what the class is.
Then I can run…
[self createOperationSubclass:MyOperationSubclass withParam:10];
[self createOperationSubclass:MyOtherOperationSubclass withParam:5];
Try this one:
Then you just call it like:
PS: Note that
classis a reserved keyword so it’s changed toaClass