mapServerRequest =“Midtown,New York,NY,USA”
var mapAddress:NSString=mapServerRequest
println(mapAddress)
var urlpath=NSString(format: "http://maps.googleapis.com/maps/api/geocode/json?address=%@", mapAddress)
println(urlpath)
var url = NSURL.URLWithString(urlpath)
println(url)
答案 0 :(得分:2)
您应该对mapAddress进行URL编码:
mapAddress.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet())