Subscribed unsubscribe Subscribe Subscribe

Mobile App Dev Diary

Android (Java, Kotlin), iOS (Swift), Xamarin (C#)

Swift 3.0

Swift 3.0 / unwrap optional values with if let statement

if let statement unwrap optional values. var value : Int? value = 5 if let value = value { //do something here print(String(value)) } If you never use unwrapped optional value inside if let statement, you can use underscore with if let . v…

Swift 3.0 / Convert String to Unix Timestamp

Convert String to Unix Timestamp in Swift version 3.0. let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" let dateString = "1970-01-01 09:00:00" let date:Date? = dateFormatter.date(from: dateString) let da…

Swift 3.0 / Convert Unix Timestamp to String

Convert Unix Timestamp to String in Swift version 3.0. let dateUnix:TimeInterval = TimeInterval() let date = Date(timeIntervalSince1970: dateUnix) let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy/MM/dd HH:mm:ss" let dat…