mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Add sanityy check
This commit is contained in:
parent
ea7991c6f4
commit
721a715045
1 changed files with 28 additions and 19 deletions
|
@ -188,36 +188,45 @@
|
|||
#pragma mark - UIAlertViewDelegate (iOS < 8)
|
||||
|
||||
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
|
||||
// Retrieve the callback
|
||||
blockCustomAlert_onClick block = [actions objectAtIndex:buttonIndex];
|
||||
if ([block isEqual:[NSNull null]] == NO) {
|
||||
// And call it
|
||||
// sanity check
|
||||
// the user could have forgotten to set the cancel button index
|
||||
if (buttonIndex < actions.count) {
|
||||
// Retrieve the callback
|
||||
blockCustomAlert_onClick block = [actions objectAtIndex:buttonIndex];
|
||||
if ([block isEqual:[NSNull null]] == NO) {
|
||||
// And call it
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
block(self);
|
||||
});
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
block(self);
|
||||
// Release alert reference
|
||||
_alert = nil;
|
||||
});
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Release alert reference
|
||||
_alert = nil;
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - UIActionSheetDelegate (iOS < 8)
|
||||
|
||||
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
|
||||
// Retrieve the callback
|
||||
blockCustomAlert_onClick block = [actions objectAtIndex:buttonIndex];
|
||||
if ([block isEqual:[NSNull null]] == NO) {
|
||||
// And call it
|
||||
|
||||
// sanity check
|
||||
// the user could have forgotten to set the cancel button index
|
||||
if (buttonIndex < actions.count) {
|
||||
// Retrieve the callback
|
||||
blockCustomAlert_onClick block = [actions objectAtIndex:buttonIndex];
|
||||
if ([block isEqual:[NSNull null]] == NO) {
|
||||
// And call it
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
block(self);
|
||||
});
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
block(self);
|
||||
// Release _alert reference
|
||||
_alert = nil;
|
||||
});
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Release _alert reference
|
||||
_alert = nil;
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue