NSURL 未使用 NSString 进行分配
这很奇怪,因为程序中的所有其他 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常这是因为字符串的格式不正确,无法编码为 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.
该字符串的格式似乎不正确。请参阅
%@&deviceid=@%@&sessionkey
部分;不应该是%@&deviceid=%@&sessionkey
吗?The string seems to not be correctly formatted. See the
%@&deviceid=@%@&sessionkey
part; should not it be%@&deviceid=%@&sessionkey
?