作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在这种情况下,我需要使用包含“.
例如:
NSString *myStringWithURL = [NSString stringWithFormat:
@"http://myurl.com/setParam.php?setName=
{\"name\":\"%@\"} ", name];
// myStringWithURL will return the desired URL but it is a String.
// of course I need it as URL in order to make the request.
NSURL *targetURL = [NSURL URLWithString : myStringWithURL];
//This will return nil.
所以问题是如何让我的 URL 不返回 nil?
{"name":"My Name"} 部分应该是一个 JSON,但这似乎比使用 NSDictionary 然后使用 JSON 的解析器等更简单。
非常感谢您的帮助!!
最佳答案
使用 stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding 来转换你的字符串
关于iphone - 对象 : Make a NSURL with a String that does not conform to RFC 2396,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4803776/
我是一名优秀的程序员,十分优秀!