'NSInvalidArgumentException',原因:'data parameter is nil' [英] 'NSInvalidArgumentException', reason: 'data parameter is nil'

查看:552
本文介绍了'NSInvalidArgumentException',原因:'data parameter is nil'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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'.


原因:xcode中的'data parameter is nil'。网址在浏览器上运行正常。

reason: 'data parameter is nil' in xcode. The url works fine on the browser.

当我删除网址的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];


推荐答案

我也有同样的问题:


因未捕获的异常而终止应用程序'NSInvalidArgumentException ',原因:'数据参数为零'

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

但我已经解决了。原因是我的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'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆