[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.
[NSURL URLWithString:] returns nil的更多相关文章
- [NSURL URLWithString:] 返回nil
具体问题原因是url中输入的有中文,那么这个就看作非法的字符无法识别.这种的必须使用post方式来发送消息.具体为: tmp = mainurl; [parameters app ...
- indexPathForCell returns nil since ios7
-(UITableViewCell*)GetCellFromTableView:(UITableView*)tableView Sender:(id)sender { CGPoint pos = [s ...
- 第六十二篇、AFN3.0封装网络请求框架,支持缓存
1.网络请求 第一种实现方式: 功能:GET POST 请求 缓存逻辑: 1.是否要刷新本地缓存,不需要就直接发起无缓存的网络请求,否则直接读取本地数据 2.需要刷新本地缓存,先读取本地数据,有就返回 ...
- iOS进阶之如何进行 HTTP Mock(转载)
这篇文章会对 OHHTTPStubs 源代码的分析,其实现原理是建立在 NSURLProtocol 的基础上的,对这部分内容不了解的读者,可以阅读这篇文章 iOS 开发中使用 NSURLProtoco ...
- [BS-27] 创建NSURL的几个方法的区别
创建NSURL的几个方法的区别 URL的基本格式 = 协议://主机地址/路径 URL和Path的区别 * URL:统一资源定位符,格式 “协议+主机名称+路径” 例如:[NSURL UR ...
- Objective-C 【从文件中读写字符串(直接读写/通过NSURL读写)】
———————————————————————————————————————————从文件中读写字符串(直接读写/通过NSURL读写) #import <Foundation/Foundati ...
- 简单使用NSURLConnection、NSURLRequest和NSURL
以下是代码,凝视也写得比較清楚: 头文件须要实现协议NSURLConnectionDelegate和NSURLConnectionDataDelegate // // HttpDemo.h // My ...
- IOS NSURL基本操作-备
NSURL其实就是我们在浏览器上看到的网站地址,这不就是一个字符串么,为什么还要在写一个NSURL呢,主要是因为网站地址的字符串都比较复杂,包括很多请求参数,这样在请求过程中需要解析出来每个部门,所以 ...
- NSURL
1. NSURL的简介 URL是对可以从互联网上得到的资源的位置和访问方法的一种简介的表示,是互联网上标准资源的地址.URL可能包含远程服务器上的资源位置,本地磁盘上的文件的路径,甚至任意一段编码的数 ...
随机推荐
- LeetCode: Construct Binary Tree from Inorder and Postorder Traversal 解题报告
Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of ...
- LeetCode: Search in Rotated Sorted Array 解题报告
Search in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you before ...
- ipconfig 命令有什么作用
ipconfig /all:显示本机TCP/IP配置的详细信息:ipconfig /release:DHCP客户端手工释放IP地址:ipconfig /renew:DHCP客户端手工向服务器刷新请求: ...
- C#学习笔记(4)——sqlserver常用语句
说明(2017-5-26 17:29:05): 需要天天练习: 新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,[字段1] ...
- iOS实现tableViewCell或collectionCell中点击界面按钮跳转
//找到父类界面 - (UIViewController *)viewController { for (UIView* next = [self superview]; next; next = n ...
- 操作Excel文件--java
java操作Excel首先要导入 JExcelAPI JExcelAPI是一套纯粹使用JAVA开发出来的Excel表格操作组件,本身并不与特定的操作系统进行绑定,可以在不同的操作系统上对Excel文件 ...
- RedHat 6 yum 使用网易源
. . . . . 刚装好了 RedHat 6 系统,但是使用 yum 的时候总是提示 nothing to do,并且什么都做不了.后来经过一番搜索才知道,红帽的 yum 在线更新是收费的,而且必须 ...
- 无法将 lambda 表达式 转换为类型“System.Delegate”,因为它不是委托类型
今天写winform的时候遇到一个问题,提示: 无法将 lambda 表达式 转换为类型“System.Delegate”,因为它不是委托类型, 主要是为了在子线程中更新UI线程,在wpf中同样的写法 ...
- linux 网络安全不完全笔记
一.安装Centos二.Linux网络网络环境设置 a.配置linux与客户机相连通 b.配置linux上网三.Yum详解 yum 的基本操作 a.使用 yum 安装新软件 yum install – ...
- redis获取当前时间精确到微秒
在redis取得当前时的方法为执行time命令 127.0.0.1:6382> time1) "1495780564"2) "894089" 第一行为以 ...