// Swift 4: 'Int??' // Swift 5: 'Int?' let result = try? database?.countOfRows(matching: predicate) // Swift 4: 'String??' // Swift 5: 'String?' let myString = try? String(data: someData, encoding: .utf8) // Swift 4: '[String: Any]??' // Swift 5: '[String: Any]?' let dict = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
let array: [Int]? = nil for? element in array { ... } // Equivalent to if let unwrappedArray = array { for element in unwrappedArray { ... } }
try?
の挙動変更と、 for?
文の追加