HEAlert 1.0.0

HEAlert 1.0.0

TestsTested
LangLanguage SwiftSwift
License BSD 3.0
ReleasedLast Release Sep 2016
SPMSupports SPM

Maintained by John Daub, John C. Daub.



HEAlert 1.0.0

HEAlert

A convenience around UIAlertController, because sometimes you just want to say “OK”.

Background and Approach

UIAlertController is awesome, but sometimes it’s too much. How many times do you want to simply alert with a message and an “OK” button? Somewhat easy with UIAlertView, certainly cumbersome with UIAlertController, but simple with HEAlert.

That’s why I created HEAlert.

Go from:

  let alertView = UIAlertView(title: "Hello World", message: nil, delegate: nil, cancelButtonTitle: "OK")
  alertView.show()

or:

let alertController = UIAlertController(title: "Hello World", message: nil, preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(action)
self.presentViewController(alertController, animated: true, completion: nil)

to:

HEAlert.ok("Hello World")

or:

HEAlert.ok("Hello World", presentingViewController: self)

Supported OS and SDK

  • Xcode 7.2.1+
  • Swift 2.1+
  • iOS 8 (minimum, required)

With v0.5, HEAlert has moved to Swift 2 and Xcode 7. If you still need Xcode 6.x (Swift 1.2) support, you can use older versions of HEAlert such as v0.4.2.

Installation

Currently supports being installed by simple source code addition, by git submodule, or by Cocoapods (preferred).

Submodule

You can easily obtain git as a submodule, and simply add HEAlert.swift to your project. Off you go!

Usage

Usage is fairly straightforward, and the code is fully documented. There’s also an example application that demonstrates a simple usage of the class.

Simple OK alert

HEAlert.ok("Hello World")

or:

HEAlert.ok("Hello World", presentingViewController: self)

OK with Message

HEAlert.ok("Hello World", message: "This is my first HEAlert", presentingViewController: self)

More Complicated

You can customize a fair portion of the HEAlert behaviors:

HEAlert.other("Do you like waffles?", message: "This is an important question", buttonTitle: "Yes", cancelTitle: "No", presentingViewController: self, cancelHandler: { (_) -> Void in
    println("Must like pancakes instead")
}) { (_) -> Void in
    println("Get the syrup!")
}

NSError

Easy display of an NSError:

HEAlert.error(anNSError, presentingViewController: self, buttonHandler: nil)

Contact

Hsoi Enterprises

Creator

Changes / Release Notes

See included CHANGELOG.md file.

License

BSD 3-clause “New” or “Revised” License. See included “License” file.