zoukankan      html  css  js  c++  java
  • [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.

  • 相关阅读:
    对我影响最大的三位导师
    global与nonlocal
    random模块
    time模块
    datetime模块
    sys模块
    os模块
    collection模块
    hashlib模块
    pickle模块
  • 原文地址:https://www.cnblogs.com/ihojin/p/nil-url.html
Copyright © 2011-2022 走看看