This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
po String.init(data: response.data!, encoding: NSUTF8StringEncoding) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var version: String? { | |
guard let dictionary = Bundle.main.infoDictionary, | |
let version = dictionary["CFBundleShortVersionString"] as? String, | |
let build = dictionary["CFBundleVersion"] as? String else {return nil} | |
let versionAndBuild: String = "vserion: \(version), build: \(build)" | |
return versionAndBuild | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func example(of description: String, action: () -> Void) { | |
print("\n--- Example of:", description, "---") | |
action() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RealmSwift | |
public struct RealmDB { | |
public static var realm: Realm? { | |
do { | |
return try Realm() | |
}catch { | |
print("error \(error.localizedDescription)") | |
return nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let now = Date() | |
let dateFormatter = NSDateFormatter() | |
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" | |
currDate.text = dateFormatter.stringFromDate(now) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func log(message: String) { | |
let thread = Thread.current.isMainThread ? "Main": "Background" | |
print("\(thread) thread: \(message)") | |
} | |
func addNumbers(upTo range: Int) -> Int { | |
log(message: "Adding numbers...") | |
return (1...range).reduce(0, +) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFRunLoopGetCurrent() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ProcessInfo.init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func processTime(blockFunction: () -> ()) { | |
let startTime = CFAbsoluteTimeGetCurrent() | |
blockFunction() | |
let processTime = CFAbsoluteTimeGetCurrent() - startTime | |
print("Processing Time = \(processTime)") | |
} |
OlderNewer