iDeveloper iDeveloper - 1 year ago 70
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 =


Answer Source

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?]

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download