-(NSInteger) buttonIndexWithMessage:(NSString *) title andArrayOfOptions:(NSArray *) options
{
self.operation=[NSOperationQueue new];
[self.operation addOperationWithBlock:^{
[[NSOperationQueue mainQueue]addOperationWithBlock:^{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
for (NSString * strOption in options) {
[actionSheet addButtonWithTitle:strOption];
}
[actionSheet showInView:[BGMDApplicationsPointers window]];
}];
self.operation.suspended=true; //Okay make t
}];
[self.operation waitUntilAllOperationsAreFinished];//Don't get out of the function till user act.
//Wait till delegate is called.
return self.buttonIndex;//I want to return buttonIndex here.
}
即使 self.operation 尚未完成,执行点也会一直移动直到返回 self.buttonIndex。