I have a dictionary as a response from server:
{
"gross_price" = "6.00";
"gross_price_total" = "6.00";
"guests_count" = 1;
}
Then I try:
let x = dictionary["gross_price_total"] as? Double
let y = dictionary["gross_price_total"]!
println("result: \(x) \(y)")
As an output I get:
result: nil 6.00
Why? Is it not a Double?
It results that my final code doesn't work:
if let grossPriceTotal = dictionary["gross_price_total"] as? Double {
println("final result: \(grossPriceTotal)")
}
"6.00"is a string, not a number. And if you search for "Swift string to double" then you should find some answers, some are already in the "Related" section ...