我在我的类中定义了以下 block :
typedef BOOL (^AlertViewShouldEnableFirstOtherButtonHandler)(AlertView *alertView);
我在我的 View Controller 中这样调用这个 block ,并返回一个 bool 值,正如 block 所期望的那样。
self.alertView.shouldEnableFirstOtherButtonHandler = ^BOOL (AlertView *alertView ) {
return YES;
}
我将如何设法获取/读取我的类中的返回值?
最佳答案
从 block 中获取返回值的唯一方法是调用它:
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);
关于ios - 从 block 中读取返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18018435/