LFAlertController 0.0.2

LFAlertController 0.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Lucas Farah.


Downloads

Total71
Week0
Month0

Installs

Apps4
powered by Segment

GitHub

Stars4
Watchers1
Forks1
Issues2
Contributors2
Pull Requests0

Code

Files1
LOCLines of Code 58


  • By
  • lucasfarah

LFAlertController

UIAlertController Swift extension with handler inside initialization 🔶

Why? Because UIAlertController has handlers inside each action, forcing the developers to have duplicated code. Instead, we can have a switch inside a global handler that is called when any action inside the UIAlertController is called

How to install

Using the Swift file:

Drag the LFAlertController.swift from /Sources to your project

Using SPM

  .Package(url: "https://github.com/awesome-labs/LFAlertController.git", majorVersion: 0)

How to Use

Initializing UIAlertActions

let action1 = UIAlertAction(title: "Second Action", style: .Default)

Initializing UIAlertController

UIAlertController with Handler

self.controller = UIAlertController(title: "hey", message: "ho", preferredStyle: .Alert,actions:[action0,action1])
{ (action,index) -> () in

  //Printing index of Action
  print("\(index) - \(action.title!)")
}
Show UIAlertController
self.controller.show()

Other options

UIAlertAction with handler

let action0 = UIAlertAction(title: "First Action", style: .Default, handler: nil)

UIAlertController without Handler

self.controller = UIAlertController(title: "hey", message: "ho", preferredStyle: .Alert, actions: [action0,action1])