Latest 1.0.2
Homepage https://github.com/Bogdan-Stasjuk/UIAlert-Blocks
License MIT
Platforms ios 6.0, requires ARC
Authors

UIAlert-Blocks

A category on UIAlertView for using blocks instead of delegation methods with enums for most standard titles and button names.

Enums for titles and buttons

typedef NS_ENUM(UInt8, UIAlertTitleType) {
    UIAlertTitleWarning,
    UIAlertTitleInfo,
    UIAlertTitleConfirm,
};

typedef NS_ENUM(UInt8, UIAlertButtonType) {
    UIAlertButtonOk,
    UIAlertButtonYes,
    UIAlertButtonNo,
};

All names can be localized or redefined in Localizable.strings files using key-value pairs below:

 // UIAlertView button's titles
 "UIALERT_BUTTON_TITLE_YES"  = "YES";
 "UIALERT_BUTTON_TITLE_NO"   = "NO";
 "UIALERT_BUTTON_TITLE_OK"   = "OK";

 // UIAlertView's titles
 "UIALERT_TITLE_WARNING"     = "Warning";
 "UIALERT_TITLE_INFO"        = "Information";
 "UIALERT_TITLE_CONFIRM"     = "Confirmation";

Static methods

+ (NSString *)titleFor:(UIAlertTitleType)alertTitleType;
+ (NSString *)buttonTitleFor:(UIAlertButtonType)alertButtonType;

Nonstatic methods

- (id)initWithTitle:(NSString *)title message:(NSString *)message;
- (id)initWithTitleType:(UIAlertTitleType)titleType message:(NSString *)message;

- (id)initWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle;
- (id)initWithTitleType:(UIAlertTitleType)titleType message:(NSString *)message buttonType:(UIAlertButtonType)buttonType;

- (id)initWithTitle:(NSString *)title message:(NSString *)message
        buttonTitle:(NSString *)buttonTitle block:(void(^)())block;
- (id)initWithTitleType:(UIAlertTitleType)titleType message:(NSString *)message
        buttonType:(UIAlertButtonType)buttonType block:(void(^)())block;

- (id)initWithTitle:(NSString *)title message:(NSString *)message
  cancelButtonTitle:(NSString *)cancelButtonTitle cancelBlock:(void(^)())cancelBlock
 proceedButtonTitle:(NSString *)proceedButtonTitle proceedBlock:(void(^)())proceedBlock;
- (id)initWithTitle:(NSString *)title message:(NSString *)message
   cancelButtonType:(UIAlertButtonType)cancelButtonType cancelBlock:(void(^)())cancelBlock
  proceedButtonType:(UIAlertButtonType)proceedButtonType proceedBlock:(void(^)())proceedBlock;
- (id)initWithTitleType:(UIAlertTitleType)titleType message:(NSString *)message
  cancelButtonType:(UIAlertButtonType)cancelButtonType cancelBlock:(void(^)())cancelBlock
 proceedButtonType:(UIAlertButtonType)proceedButtonType proceedBlock:(void(^)())proceedBlock;

Demo

Clone project and run it. You can find examples of usage at TestViewController.m. Examples of localization you can see at UIAlert+BlocksExample/Resources/Localizations.

Compatibility

This class has been tested back to iOS 6.0.

Installation

Cocoapods: pod 'UIAlert+Blocks'
Manual: Copy the UIAlert+Blocks folder in your project

Import header in your project. .pch is a good place ;)

#import "UIAlert+Blocks.h"

License

This code is released under the MIT License. See the LICENSE file for
details.

Latest podspec

{
    "name": "UIAlert+Blocks",
    "version": "1.0.2",
    "summary": "A category on UIAlertView for using blocks instead of delegate methods with enums for most standard titles and button names.",
    "description": "A cetogory on UIAlertView that adds blocks and button titles enums. Handy and clear methods that save from using delegation.",
    "homepage": "https://github.com/Bogdan-Stasjuk/UIAlert-Blocks",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Bogdan Stasjuk": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Bogdan-Stasjuk/UIAlert-Blocks.git",
        "tag": "1.0.2"
    },
    "social_media_url": "https://twitter.com/Bogdan_Stasjuk",
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "source_files": "UIAlert+Blocks/*.{h,m}",
    "public_header_files": "UIAlert+Blocks/*.h"
}

Pin It on Pinterest

Share This