-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.swift
More file actions
50 lines (42 loc) · 1.82 KB
/
Copy pathHelper.swift
File metadata and controls
50 lines (42 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Helper.swift
// CustomerTruckBooking
//
// Created by http://amith.me.uk on 11/26/17.
// Copyright © 2017 Amith Ranasinghe. All rights reserved.
//
import UIKit
class Helper: NSObject {
class func validateTextField(textField: UITextField) -> Bool {
if textField.text == nil || textField.text == "" {
return false
}
return true
}
class func showAlert(_ title: String,
message: String ,
buttonTitles: String ..., viewController: UIViewController,
completion: @escaping (Int) -> Void) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
for (buttonIndex, buttonTitle) in buttonTitles.enumerated() {
let action = UIAlertAction(title: buttonTitle, style: .default, handler: { (action) in
completion(buttonIndex)
})
alertController.addAction(action)
}
viewController.present(alertController, animated: true, completion: nil)
}
class func showActionSheet(_ title: String,
message: String,
buttonTitles: String ..., viewController: UIViewController,
completion: @escaping (Int) -> Void) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
for (buttonIndex, buttonTitle) in buttonTitles.enumerated() {
let action = UIAlertAction(title: buttonTitle, style: .default, handler: { (action) in
completion(buttonIndex)
})
alertController.addAction(action)
}
viewController.present(alertController, animated: true, completion: nil)
}
}