本文介绍了使用 Xcode6.1 的 NSURL 的奇怪问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Xcode6.1
_mainURl 是我的ServerLink"
_mainURl is my ' ServerLink '
服务是GetUserById"
service is ' GetUserById '
NSString* str = [NSString stringWithFormat:@"%@%@",_mainURl,service];
NSURL *url = [NSURL URLWithString:str];
当我附加两个字符串并使用 NSURL
创建一个 url 时,url 得到 'null'
When I append two strings and Create a url with NSURL
, url getting 'null'
但是,当我直接给出服务器链接后跟 serviceName 时,我可以生成 URL.
But, When I directly given the server link followed by serviceName I can generate URL.
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"ServerLink/GetUserById"]];
推荐答案
NSString* str = [NSString stringWithFormat:@"%@/%@",_mainURl,service];
NSURL *url = [NSURL URLWithString:str];
你不试试这样吗??
我想我不确定你到底有什么问题,但正如你的波纹管描述,我想你离开了这部分
i think i am not sure exact what issue having you but as your bellow description, i think you left this part
这篇关于使用 Xcode6.1 的 NSURL 的奇怪问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!