[NSURL URLWithString:] returns nil

You need to escape the non-ASCII characters in your hardcoded URL as well:

//localisationName is a arbitrary string here
NSString* webName =[localisationName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString* stringURL =[NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@,Montréal,Communauté-Urbaine-de-Montréal,Québec,Canadae&output=csv&oe=utf8&sensor=false", webName];
NSString* webStringURL =[stringURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL* url =[NSURL URLWithString:webStringURL];

You can probably remove the escaping of the localisationName since it will be handled by the escaping of the whole string.

posted @ 2013-12-02 17:08  有妄想症的猫zz  阅读(1284)  评论(0编辑  收藏  举报