I have been trying to write a delegate to a view controller which has a method which will call back the sender when it is done
-(void) doSomething:(id)target action:(SEL)action object:(id)object{
//Do Some work
//Produce an NSArray* called array
object = array;
if([target respondsToSelector:action])
{
[target action];
}
}
The idea being that the action method in the sender also has a reference to object and it can read the results and do something once the selector has been called to use the data.
The problem I am having is that [target respondsToSelector:action] returns true so the code tries to call the selector but then I get an SIGABRT signal and the message that NSObject -doesNotRegogniseSelector.
Does anyone know where I am going wrong?
Try:
Typing
[target action]is not how to dynamically call a method. It would be like calling[anObject @selector(doSomething)]. Also, it’s probably not needed to check whethertargetresponds toselector, since your method is being called with those as parameters, and it would be a mistake on the caller’s part to pass in a bad selector.