已采纳回答 / 慕数据021159
先上代码:var name = Optional.some("daniel") name = Optional.none首先:对题主提问中对表表述做一点点更正。也许更正了这个也就同时解决了题主对提问“就是说这个值是属于Optional里面的‘.none类型 ’而他不是属于Optional里面的‘.some类型 ’?”其中.‘.none类型 ’不应该称之为一种“类型”,‘.some类型 ’也不应该称之为一种“类型”。它们两个都是“Optional类型”这种类型的一个枚举值。顺便说一下,至于“Op...
2019-01-13
swift 4.2.1
guard let preIndex = str.range(of: ",")?.lowerBound else {return nil} guard let sufIndex = str.range(of: ",")?.upperBound else{return nil}
guard let first = Double(str.prefix(upTo: preIndex)) else{return nil}
guard let second = Double(str.suffix(from: sufIndex)) else{return nil}
guard let preIndex = str.range(of: ",")?.lowerBound else {return nil} guard let sufIndex = str.range(of: ",")?.upperBound else{return nil}
guard let first = Double(str.prefix(upTo: preIndex)) else{return nil}
guard let second = Double(str.suffix(from: sufIndex)) else{return nil}
2018-11-17
let preIndex = str.range(of: ",")!.lowerBound
let sufIndex = str.range(of: ",")!.upperBound
let first = str.prefix(upTo: preIndex)
let second = str.suffix(from: sufIndex)
latitude = Double(first) ?? 0
longitude = Double(second) ?? 0
let sufIndex = str.range(of: ",")!.upperBound
let first = str.prefix(upTo: preIndex)
let second = str.suffix(from: sufIndex)
latitude = Double(first) ?? 0
longitude = Double(second) ?? 0
2018-11-17