Reputation: 152
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)
Upvotes: 0
Views: 118
Reputation: 4264
You should URL encode your mapAddress:
mapAddress.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLPathAllowedCharacterSet())
Upvotes: 2