2
試圖在我的Swift代碼中添加一個單引號字符,但它不斷地添加一個\',這對於API調用來說是必然的。Swift中的單引號字符
我的代碼是:
let locationLat = String(format: "%f", (currentLocation?.coordinate.latitude)!)
let locationLong = String(format: "%f", (currentLocation?.coordinate.longitude)!)
let apiLocation = "$filter=geo.distance(Location,geographyPoint" + "(" + locationLat + locationLong + ")) le 0.1"
我需要做apiLocation變量的樣子:
$filter=geo.distance(Location, geography'POINT(lat, long)') le 0.5&searchMode=all&$count=true
讓我知道,謝謝。
實際報價......?順便說一句,你可以使用'toString)'在float/double上,不需要'String(format:)' – Alexander
你不需要轉義''',只需在字符串中輸入並使用[interpolation] ://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html#//apple_ref/doc/uid/TP40014097-CH7-ID292)。 – Moritz