Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
/ HEAlert Public archive

A convenience around UIAlertController, because sometimes you just want to say "OK"

License

Notifications You must be signed in to change notification settings

HsoiEnterprises/HEAlert

Repository files navigation

Build Status Cocoapods Compatible License Platform

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 8.0+
  • Swift 3+
  • iOS 8 (minimum, required)

With v1.0, HEAlert has moved to Swift 3 and Xcode 8. If you need need Swift 2.2 support, use the v0.5.3 tag. There has been no explicit effort to support Swift 2.3.

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!

Cocoapods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:

$ gem install cocoapods

To integrate HEAlert into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'HEAlert'

Then, run the following command:

$ pod install

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.

About

A convenience around UIAlertController, because sometimes you just want to say "OK"

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages