CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

GKBlocks 0.0.2

GKBlocks 0.0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Georg Kitz.



GKBlocks 0.0.2

Addition for UIActionSheet and UIAlertView to support a block instead of a delegate to check which button was tapped

Install

pod 'GKBlocks'

or you can use the subspecs to install it:

pod 'GKBlocks/UIActionSheet'
pod 'GKBlocks/UIAlertView'

Usage

UIActionSheet and UIAlertView are extended with 2 init methods which support a block as parameter. For UIActionSheet:

GKActionSheetBlock block = ^(UIActionSheet *sheet, NSInteger buttonIndex) {
        NSLog(@"CancelButton Pressed = %d", sheet.cancelButtonIndex == buttonIndex);
    };

    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Test" block:block cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"OK", nil];
    [sheet showInView:self.view];

For UIAlertView:

GKAlertViewBlock block = ^(UIAlertView *alertView, NSInteger buttonIndex) {
        NSLog(@"CancelButton Pressed = %d", alertView.cancelButtonIndex == buttonIndex);
    };

    [[[UIAlertView alloc] initWithTitle:@"Test" message:@"This is a test" block:block cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil] show];

Author

Georg Kitz, @gekitz