Reputation: 1928
I have the following block defined in my class:
typedef BOOL (^AlertViewShouldEnableFirstOtherButtonHandler)(AlertView *alertView);
I call this block like so in my viewcontroller and return a boolean, as expected by the block.
self.alertView.shouldEnableFirstOtherButtonHandler = ^BOOL (AlertView *alertView ) {
return YES;
}
How would I manage to get/read the return value in my class?
Upvotes: 2
Views: 150
Reputation: 727047
The only way of getting a return value from a block is to invoke it:
UIAlertView *av = [[UIAlertView alloc]
initWithTitle:@"Quick brown"
message:@"fox jumps"
delegate:self
cancelButtonTitle:@"over the"
otherButtonTitles:@"Lazy dog",
nil];
BOOL blockResult = self.alertView.shouldEnableFirstOtherButtonHandler(av);
Upvotes: 7