Latest 3.0.1
License MIT
Platforms ios 5.0, requires ARC
Frameworks Foundation, UIKit


About this class

This class make it easier to use Alert Views with blocks, and make the transition between UIAlertView (iOS < 8.0) to UIAlertController (iOS 8.0+)

This allows you to provide directly the code to execute (as a block) in return to the tap on a button,
instead of declaring a delegate and implementing the corresponding methods.

This also has the huge advantage of simplifying the code especially when using multiple UIAlertViews in the same object (as in such case, it is not easy to have a clean code if you share the same delegate)

Note: You may also be interested in OHActionSheet

Usage Example

[OHAlertView showAlertWithTitle:@"Alert Demo"
                        message:@"You like this sample?"
                  buttonHandler:^(OHAlertView* alert, NSInteger buttonIndex)
     NSLog(@"button tapped: %d",buttonIndex);

     if (buttonIndex == alert.cancelButtonIndex) {
     } else {


This class is referenced in CocoaPods, so you can simply add pod OHAlertView to your Podfile to add it to your pods.

Compatibility Notes

  • This class uses blocks, which is a feature introduced in iOS 4.0.
  • This class uses ARC.
  • This class internally uses UIAlertView if you are targeting iOS < 8.0, and use UIAlertController if you are targeting iOS8 or above


This code is under MIT License.

Latest podspec

    "name": "OHAlertView",
    "version": "3.0.1",
    "summary": "AlertView helper with blocks and a simple to use API. Uses UIAlertController in iOS 8+, UIAlertView otherwise.",
    "description": "AlertView helper that uses blocks to handle its callback.nn * If your deployment target is eariler than iOS 8, this will use UIAlertViewn * If your deployment target is iOS 8 or above, this will use the new UIAlertController",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Olivier Halligon": "[email protected]"
    "source": {
        "git": "",
        "tag": "3.0.1"
    "source_files": "OHAlertView/*.{m,h}",
    "public_header_files": "OHAlertView/*.h",
    "frameworks": [
    "requires_arc": true,
    "platforms": {
        "ios": "5.0"

Pin It on Pinterest

Share This