Last active
December 10, 2015 00:48
-
-
Save felixflores/4353703 to your computer and use it in GitHub Desktop.
Make Action Sheet a little bit more sane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIViewController+ActionSheet.h | |
// Tweaks | |
// | |
// Created by Felix Flores on 12/21/12. | |
// Copyright (c) 2012 felixflor.es. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@protocol FFActionSheetDelegate <UIActionSheetDelegate> | |
@optional | |
- (void)actionSheetAction__ActionSheetTitle__:(UIActionSheet *)actionSheet clickedButtonWithTitle:(NSString *)buttonTitle; | |
@end | |
@interface UIViewController (ActionSheet) | |
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIViewController+ActionSheet.m | |
// Tweaks | |
// | |
// Created by Felix Flores on 12/21/12. | |
// Copyright (c) 2012 felixflor.es. All rights reserved. | |
// | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
#import "UIViewController+ActionSheet.h" | |
@implementation UIViewController (ActionSheet) | |
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex | |
{ | |
NSString *actionSheetTitle = [actionSheet title]; | |
NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex]; | |
NSString *selectorString = [NSString stringWithFormat:@"actionSheet%@:clickedButtonWithTitle:", actionSheetTitle]; | |
SEL selector = NSSelectorFromString(selectorString); | |
if ([self respondsToSelector:selector]) { | |
[self performSelector:selector withObject:actionSheetTitle withObject:buttonTitle]; | |
} | |
} | |
#pragma clang diagnostic pop | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment