Skip to content

Instantly share code, notes, and snippets.

@blixt
Created January 29, 2015 23:18
Show Gist options
  • Save blixt/4bb46c0672ed8facb19a to your computer and use it in GitHub Desktop.
Save blixt/4bb46c0672ed8facb19a to your computer and use it in GitHub Desktop.
@interface AlertViewCallback : NSObject <UIAlertViewDelegate>
@property (copy, nonatomic) void (^callback)(void);
@end
@implementation AlertViewCallback
+ (instancetype)callback:(void (^)(void))callback {
return [[self alloc] initWithCallback:callback];
}
- (instancetype)initWithCallback:(void (^)(void))callback {
self = [super init];
if (self) {
self.callback = callback;
}
return self;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
self.callback();
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment