Using inheritance.
I have a child class that calls a method in the parent class that runs calls the server API.
-(IBAction)buttonPressed
{
[self methodInParentClassThatCallsTheAPI:param];
// This is where I would like the call back
if (success from the server API) // do something with the UI
else if (failure from the server API) // do so something else with the UI
}
Parent Class:
- (void)methodInParentClassThatCallsTheAPI:(NSString *)param
{
//The method below calls the server API and waits for a response.
[someServerOperation setCompletionBlockWithSuccess:^(param, param){
// Return a success flag to the Child class that called this method
} failure:^(param, NSError *error){
// Return a failure flag to the Child class that called this method
}
}
How can I accomplish this with a block? Is there a better way to do this other than the block? Code example please