Extensions.swift 1.06 KB
Newer Older
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//
//  Extensions.swift
//  App16
//
//  Created by Grigor Aghabalyan on 3/25/20.
//  Copyright © 2020 X-TECH. All rights reserved.
//

import UIKit

func getController<T: UIViewController>() -> T {
    return T(nibName: String(describing: T.self), bundle: nil)
}

func changeRoot(_ controller: UIViewController) {
    UIApplication.shared.keyWindow?.rootViewController = controller
}
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
18
19
20
21
22
23
24
25
26

extension Date {
    
    func toString( dateFormat format  : String ) -> String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = format
        return dateFormatter.string(from: self)
    }
}
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

extension Bundle {

    class var applicationVersionNumber: String {
        if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
            return version
        }
        return "Version Number Not Available"
    }

    class var applicationBuildNumber: String {
        if let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String {
            return build
        }
        return "Build Number Not Available"
    }
}