Added new methods about appstate to EZSwiftFunctions.swift

This commit is contained in:
Goktug Yilmaz 2016-04-07 11:13:24 +03:00
parent 68e8c8c1c4
commit 4e35ac2f66
2 changed files with 41 additions and 3 deletions

View File

@ -12,9 +12,6 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
} }
} }

View File

@ -46,6 +46,42 @@ public struct ez {
return String.fromCString(machine)! return String.fromCString(machine)!
} }
/// EZSE: Returns true if DEBUG mode is active //TODO: Add to readme
public static var isDebug: Bool {
#if DEBUG
return true
#else
return false
#endif
}
/// EZSE: Returns true if RELEASE mode is active //TODO: Add to readme
public static var isRelease: Bool {
#if DEBUG
return false
#else
return true
#endif
}
/// EZSE: Returns true if its simulator and not a device //TODO: Add to readme
public static var isSimulator: Bool {
#if (arch(i386) || arch(x86_64)) && os(iOS)
return true
#else
return false
#endif
}
/// EZSE: Returns true if its on a device and not a simulator //TODO: Add to readme
public static var isDevice: Bool {
#if (arch(i386) || arch(x86_64)) && os(iOS)
return false
#else
return true
#endif
}
/// EZSE: Returns the top ViewController /// EZSE: Returns the top ViewController
public static var topMostVC: UIViewController? { public static var topMostVC: UIViewController? {
var presentedVC = UIApplication.sharedApplication().keyWindow?.rootViewController var presentedVC = UIApplication.sharedApplication().keyWindow?.rootViewController
@ -106,6 +142,11 @@ public struct ez {
} }
} }
/// EZSE: Returns the locale country code. An example value might be "ES". //TODO: Add to readme
public static var currentRegion: String? {
return NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as? String
}
/// EZSE: Calls action when a screen shot is taken /// EZSE: Calls action when a screen shot is taken
public static func detectScreenShot(action: () -> ()) { public static func detectScreenShot(action: () -> ()) {
let mainQueue = NSOperationQueue.mainQueue() let mainQueue = NSOperationQueue.mainQueue()