iDeveloper iDeveloper - 4 months ago 14
Swift Question

Cannot convert value of type '[String]?' to expected argument type 'String' Swift

I got lat long from API in string format now i want to change it to double.

let latitudeAll = [String]()

let double =



You need to access the particular array object with its index.

if latitudeAll.count > 0 {
    let double = NSNumberFormatter().numberFromString(latitudeAll[0])?.doubleValue

if you want Double Array from String array use this.

var doubleArr = { Double($0) }

Here doubleArr is type of [Double?]