Latest 1.0
Homepage https://github.com/dalu93/SimplyAlert
License MIT
Platforms ios 8.0, requires ARC
Authors

Build Status
Cocoapods version

Swifty way to use UIAlertController and UIAlertAction

Example

Initialize UIAlertAction easily.

// Here I'm using the default text that is "Cancel". You can override it
// by calling `UIAlertAction.Cancel("My text") { print($0) }`
let cancelAction = UIAlertAction.Cancel { print($0) }

Initialize your UIAlertController extremely fast and add your action to it. Then present it

// Using the chain provided by `add(_:)` that returns 
// the same `UIAlertController` instance
let _ = UIAlertController.alertWith(
    title: "My title",
    message: "My message"
).add(cancelAction)
.presentIn(self) // self is the UIViewController instance

This is exactly equivalent to

let cancelAction = UIAlertAction(
    title: "Cancel",
    style: .Cancel,
    handler: { print($0) }
)

let alert = UIAlertController(
    title: "My title",
    message: "My message",
    preferredStyle: .Alert
)

alert.addAction(cancelAction)

presentViewController(
    alert,
    animated: true,
    completion: nil
)

Installation

pod 'SimplyAlert', '~> 1.0'
import PackageDescription

let package = Package(
    name: "SimplyAlert",
    dependencies: [
        .Package(url: "https://github.com/dalu93/SimplyAlert", "1.0"),
    ]
)

License

SimplyAlert is under MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SimplyAlert",
    "version": "1.0",
    "summary": "Swifty way to use `UIAlertController`",
    "description": "SimplyAlert is a simple extension around `UIAlertAction` and `UIAlertController` that provides a better swifty experience using UIKit",
    "homepage": "https://github.com/dalu93/SimplyAlert",
    "license": "MIT",
    "authors": {
        "Luca D'Alberti": "[email protected]"
    },
    "social_media_url": "https://twitter.com/DAlbertiLuca",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/dalu93/SimplyAlert.git",
        "tag": "1.0"
    },
    "source_files": "Source/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This