Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

Commit

Permalink
Fix alert view availability conflict on modern Clang
Browse files Browse the repository at this point in the history
  • Loading branch information
zwaldowski committed Jan 22, 2016
1 parent 06977e8 commit a4368c8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion BlocksKit/BKDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#endif

#if !defined(BK_ALERT_CONTROLLER_DEPRECATED)
# define BK_ALERT_CONTROLLER_DEPRECATED NS_DEPRECATED_IOS(2_0, 8_0, "The BlocksKit extensions for UIAlertView and UIActionSheet are deprecated. Use UIAlertController instead.");
# define BK_ALERT_CONTROLLER_DEPRECATED(intro) NS_DEPRECATED_IOS(intro, 8_0, "The BlocksKit extensions for UIAlertView and UIActionSheet are deprecated. Use UIAlertController instead.");
#endif

#if !defined(BK_URL_CONNECTION_DEPRECATED)
Expand Down
24 changes: 12 additions & 12 deletions BlocksKit/UIKit/UIActionSheet+BlocksKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
@param title The header of the action sheet.
@return A newly created action sheet.
*/
+ (instancetype)bk_actionSheetWithTitle:(NSString *)title BK_ALERT_CONTROLLER_DEPRECATED;
+ (instancetype)bk_actionSheetWithTitle:(NSString *)title BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** Returns a configured action sheet with only a title and cancel button.
@param title The header of the action sheet.
@return An instantiated actionSheet.
*/
- (instancetype)bk_initWithTitle:(NSString *)title BK_INITIALIZER BK_ALERT_CONTROLLER_DEPRECATED;
- (instancetype)bk_initWithTitle:(NSString *)title BK_INITIALIZER BK_ALERT_CONTROLLER_DEPRECATED(2_0);

///-----------------------------------
/// @name Adding buttons
Expand All @@ -60,7 +60,7 @@
@param title The text of the button.
@param block A block of code.
*/
- (NSInteger)bk_addButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED;
- (NSInteger)bk_addButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** Set the destructive (red) button with an associated code block.
Expand All @@ -71,7 +71,7 @@
@param title The text of the button.
@param block A block of code.
*/
- (NSInteger)bk_setDestructiveButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED;
- (NSInteger)bk_setDestructiveButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** Set the title and trigger of the cancel button.
Expand All @@ -84,7 +84,7 @@
@param title The text of the button.
@param block A block of code.
*/
- (NSInteger)bk_setCancelButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED;
- (NSInteger)bk_setCancelButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED(2_0);

///-----------------------------------
/// @name Altering actions
Expand All @@ -95,14 +95,14 @@
@param block A code block, or nil to set no response.
@param index The index of a button already added to the action sheet.
*/
- (void)bk_setHandler:(void (^)(void))block forButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED;
- (void)bk_setHandler:(void (^)(void))block forButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block that is to be fired when a button is pressed.
@param index The index of a button already added to the action sheet.
@return A code block, or nil if no block is assigned.
*/
- (void (^)(void))bk_handlerForButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED;
- (void (^)(void))bk_handlerForButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired when the action sheet is dismissed with the cancel
button and/or action.
Expand All @@ -112,18 +112,18 @@
you can set this property multiple times and multiple cancel buttons will
not be generated.
*/
@property (nonatomic, copy, setter = bk_setCancelBlock:) void (^bk_cancelBlock)(void) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setCancelBlock:) void (^bk_cancelBlock)(void) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired before the action sheet will show. */
@property (nonatomic, copy, setter = bk_setWillShowBlock:) void (^bk_willShowBlock)(UIActionSheet *actionSheet) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setWillShowBlock:) void (^bk_willShowBlock)(UIActionSheet *actionSheet) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired when the action sheet shows. */
@property (nonatomic, copy, setter = bk_setDidShowBlock:) void (^bk_didShowBlock)(UIActionSheet *actionSheet) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setDidShowBlock:) void (^bk_didShowBlock)(UIActionSheet *actionSheet) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired before the action sheet will dismiss. */
@property (nonatomic, copy, setter = bk_setWillDismissBlock:) void (^bk_willDismissBlock)(UIActionSheet *actionSheet, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setWillDismissBlock:) void (^bk_willDismissBlock)(UIActionSheet *actionSheet, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired after the action sheet dismisses. */
@property (nonatomic, copy, setter = bk_setDidDismissBlock:) void (^bk_didDismissBlock)(UIActionSheet *actionSheet, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setDidDismissBlock:) void (^bk_didDismissBlock)(UIActionSheet *actionSheet, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

@end
5 changes: 5 additions & 0 deletions BlocksKit/UIKit/UIActionSheet+BlocksKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#import "NSObject+A2DynamicDelegate.h"
#import "NSObject+A2BlockDelegate.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

#pragma mark Custom delegate

@interface A2DynamicUIActionSheetDelegate : A2DynamicDelegate <UIActionSheetDelegate>
Expand Down Expand Up @@ -179,3 +182,5 @@ - (void)bk_setCancelBlock:(void (^)(void))block
}

@end

#pragma clang diagnostic pop
28 changes: 14 additions & 14 deletions BlocksKit/UIKit/UIAlertView+BlocksKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@
@return The UIAlertView.
*/
+ (instancetype)bk_showAlertViewWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles handler:(void (^)(UIAlertView *alertView, NSInteger buttonIndex))block BK_ALERT_CONTROLLER_DEPRECATED;
+ (instancetype)bk_showAlertViewWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles handler:(void (^)(UIAlertView *alertView, NSInteger buttonIndex))block BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** Creates and returns a new alert view with only a title and cancel button.
@param title The title of the alert view.
@return A newly created alert view.
*/
+ (instancetype)bk_alertViewWithTitle:(NSString *)title BK_ALERT_CONTROLLER_DEPRECATED;
+ (instancetype)bk_alertViewWithTitle:(NSString *)title BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** Creates and returns a new alert view with only a title, message, and cancel button.
@param title The title of the alert view.
@param message The message content of the alert.
@return A newly created alert view.
*/
+ (instancetype)bk_alertViewWithTitle:(NSString *)title message:(NSString *)message BK_ALERT_CONTROLLER_DEPRECATED;
+ (instancetype)bk_alertViewWithTitle:(NSString *)title message:(NSString *)message BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** Returns a configured alert view with only a title, message, and cancel button.
@param title The title of the alert view.
@param message The message content of the alert.
@return An instantiated alert view.
*/
- (instancetype)bk_initWithTitle:(NSString *)title message:(NSString *)message BK_INITIALIZER BK_ALERT_CONTROLLER_DEPRECATED;
- (instancetype)bk_initWithTitle:(NSString *)title message:(NSString *)message BK_INITIALIZER BK_ALERT_CONTROLLER_DEPRECATED(2_0);

///-----------------------------------
/// @name Adding buttons
Expand All @@ -83,14 +83,14 @@
@param title The text of the button.
@param block A block of code.
*/
- (NSInteger)bk_addButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED;
- (NSInteger)bk_addButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** Set the title and trigger of the cancel button.
@param title The text of the button.
@param block A block of code.
*/
- (NSInteger)bk_setCancelButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED;
- (NSInteger)bk_setCancelButtonWithTitle:(NSString *)title handler:(void (^)(void))block BK_ALERT_CONTROLLER_DEPRECATED(2_0);

///-----------------------------------
/// @name Altering actions
Expand All @@ -101,14 +101,14 @@
@param block A code block, or nil to set no response.
@param index The index of a button already added to the action sheet.
*/
- (void)bk_setHandler:(void (^)(void))block forButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED;
- (void)bk_setHandler:(void (^)(void))block forButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block that is to be fired when a button is pressed.
@param index The index of the button already added to the alert view.
@return A code block, or nil if no block yet assigned.
*/
- (void (^)(void))bk_handlerForButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED;
- (void (^)(void))bk_handlerForButtonAtIndex:(NSInteger)index BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired when the action sheet is dismissed with the cancel
button.
Expand All @@ -117,21 +117,21 @@
property multiple times but multiple cancel buttons will
not be generated.
*/
@property (nonatomic, copy, setter = bk_setCancelBlock:) void (^bk_cancelBlock)(void) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setCancelBlock:) void (^bk_cancelBlock)(void) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired before the alert view will show. */
@property (nonatomic, copy, setter = bk_setWillShowBlock:) void (^bk_willShowBlock)(UIAlertView *alertView) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setWillShowBlock:) void (^bk_willShowBlock)(UIAlertView *alertView) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired when the alert view shows. */
@property (nonatomic, copy, setter = bk_setDidShowBlock:) void (^bk_didShowBlock)(UIAlertView *alertView) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setDidShowBlock:) void (^bk_didShowBlock)(UIAlertView *alertView) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired before the alert view will dismiss. */
@property (nonatomic, copy, setter = bk_setWillDismissBlock:) void (^bk_willDismissBlock)(UIAlertView *alertView, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setWillDismissBlock:) void (^bk_willDismissBlock)(UIAlertView *alertView, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired after the alert view dismisses. */
@property (nonatomic, copy, setter = bk_setDidDismissBlock:) void (^bk_didDismissBlock)(UIAlertView *alertView, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_setDidDismissBlock:) void (^bk_didDismissBlock)(UIAlertView *alertView, NSInteger buttonIndex) BK_ALERT_CONTROLLER_DEPRECATED(2_0);

/** The block to be fired to determine whether the first non-cancel should be enabled */
@property (nonatomic, copy, setter = bk_SetShouldEnableFirstOtherButtonBlock:) BOOL (^bk_shouldEnableFirstOtherButtonBlock)(UIAlertView *alertView) NS_AVAILABLE_IOS(5_0) BK_ALERT_CONTROLLER_DEPRECATED;
@property (nonatomic, copy, setter = bk_SetShouldEnableFirstOtherButtonBlock:) BOOL (^bk_shouldEnableFirstOtherButtonBlock)(UIAlertView *alertView) BK_ALERT_CONTROLLER_DEPRECATED(5_0);

@end
5 changes: 5 additions & 0 deletions BlocksKit/UIKit/UIAlertView+BlocksKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#import "NSObject+A2BlockDelegate.h"
#import "NSObject+A2DynamicDelegate.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

#pragma mark Delegate

@interface A2DynamicUIAlertViewDelegate : A2DynamicDelegate <UIAlertViewDelegate>
Expand Down Expand Up @@ -223,3 +226,5 @@ - (void)bk_setCancelBlock:(void (^)(void))block
}

@end

#pragma clang diagnostic pop

0 comments on commit a4368c8

Please sign in to comment.