gpt4 book ai didi

iphone - 对象 : Make a NSURL with a String that does not conform to RFC 2396

转载 作者:搜寻专家 更新时间:2023-10-30 20:04:13 25 4
gpt4 key购买 nike

在这种情况下,我需要使用包含“.

例如:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com