我想创建一个显示 UIActionSheet 的函数,等到用户按下按钮然后返回按下的按钮
@interface UIActionSheetHandler () <UIActionSheetDelegate>
@end
@implementation UIActionSheetHandler
-(NSInteger) buttonIndexWithMessage:(NSString *) title andArrayOfOptions:(NSArray *) options
{
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]];
//Wait till delegate is called.
return 0;//I want to return buttonIndex here.
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
//What should I put it here
}
@end
我如何使//等待,直到调用委托来等待?哦,我不想让主线程等待,但我想我可以解决那个问题。