NSURL 未使用 NSString 进行分配

发布于 2024-09-09 00:19:44 字数 606 浏览 2 评论 0原文

这很奇怪,因为程序中的所有其他 NSUrl 都工作正常,但这个 NSUrl 没有分配给 NSString。我正在使用:

urlStr_ = [NSString stringWithFormat:@"http://192.168.10.2/justmeans/trunk/appaddgoodwork?gencode=%@&deviceid=@%@&sessionkey=%@&userid=%@&updatetext=%@&companyid=%d&service_type=%@",securitycode,deviceId,sessionKey,userId,finalTextInTxtVw,companyId,service_type];
urlStr_ = [urlStr_ stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)NSUTF8StringEncoding];

url_ = [[NSURL alloc] initWithString:urlStr_];

NSUrl 未分配的可能原因有哪些?有人可以帮忙吗?

提前致谢。

PS NSString 不为空。

This' strange because all my other NSUrls in program are working properly but this one isn't getting allocated with NSString. I'm using:

urlStr_ = [NSString stringWithFormat:@"http://192.168.10.2/justmeans/trunk/appaddgoodwork?gencode=%@&deviceid=@%@&sessionkey=%@&userid=%@&updatetext=%@&companyid=%d&service_type=%@",securitycode,deviceId,sessionKey,userId,finalTextInTxtVw,companyId,service_type];
urlStr_ = [urlStr_ stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)NSUTF8StringEncoding];

url_ = [[NSURL alloc] initWithString:urlStr_];

What are the possible reasons for NSUrl not getting allocated? Can anybody please help?

Thanx in advance.

P.S. NSString is not empty.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩心不撩汉 2024-09-16 00:19:44

通常这是因为字符串的格式不正确,无法编码为 URL。尝试截断字符串的各个部分以找到有问题的部分。

Useally it is because the string is not formatted correctly for encoding as an URL. Try to chop of bits of the string to find the offending part.

离线来电— 2024-09-16 00:19:44

该字符串的格式似乎不正确。请参阅%@&deviceid=@%@&sessionkey部分;不应该是%@&deviceid=%@&sessionkey吗?

The string seems to not be correctly formatted. See the %@&deviceid=@%@&sessionkey part; should not it be %@&deviceid=%@&sessionkey?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文