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
//デリゲートが呼び出されて待機するまで待機するにはどうすればよいですか?ああ、メインスレッドを待たせたくないのですが、それは解決できると思います。