问题描述
XCode新手在这里,我一直试图弄清楚为什么会发生以下情况...
XCode newbie here and i have been trying to figure out why the following is happening...
随着代码的编写方式,我不断得到' NSInvalidArgumentException的。
With the way the code is currently written, i keep getting 'NSInvalidArgumentException'.
当我删除网址的filters =%7B%22region%22%3A%22CA%22%7D部分时,它在Xcode中工作正常,但是当包含url的这一部分时,就是我收到错误消息的时候。我已经尝试使用\代替%22但仍然没有。任何建议都非常感谢。
When I remove the "filters=%7B%22region%22%3A%22CA%22%7D" part of the url, it works fine in Xcode, but when this section of the url is included, that's when I get the error message. I have tried using \" in replacement of the %22 but still nothing. Any suggestions are greatly appreciated.
NSURL *url = [NSURL URLWithString:[@"http://api.v3.factual.com/t/restaurants-us?q=peets+coffee&filters=%7B%22region%22%3A%22CA%22%7D&KEY=p7kwKMFUSyVi64FxnqWmeSDEI41kzE3vNWmwY9Zi"stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSData *data = [NSData dataWithContentsOfURL: url];
推荐答案
我也有同样的问题:
但我已经解决了。原因是我的API网址不正确。请检查你的API网址。祝你好运!
But I had solved it. The reason is my API URL is incorrect. Please check out your API URL. Good luck for you!
这篇关于'NSInvalidArgumentException',原因:'data parameter is nil'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!