I guess with all changes happening in other parts of the iOS, UIAlertView is not at the top of the Apple dev's TO-DO list. Even though Objective-C world has been enjoying blocks for couple years now, there are still no block-ified UIAlertView API :(. Luckily it is quite simple to rectify this minor omission. Take a look at this gist. Just few lines of Objective-C and you can do this:
LBAlertView *alert = [[LBAlertViewalloc] initWithTitle:@"Title"message: nildelegate:selfcancelButtonTitle:@"Cancel"otherButtonTitles: @"Enter", nil];
alert.onClickBlock = ^(UIAlertView* alertView, int buttonIndex) {
if (buttonIndex == 1) {
// do something
}
else {
// do something else
}
};
[alert show];
Share and enjoy !