NSData dataWithContentsOfURL
我有这个按钮点击(下载)的方法。问题是它由于异常而终止:
[Session started at 2011-03-14 13:06:45 +0530.] 2011-03-14 13:06:45.710 XML[7079:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString isFileURL]: unrecognized selector sent to instance 0x62b8'
-(IBAction) download
{
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:@"http://ws.cdyne.com/WeatherWS/Images/thunderstorms.gif"]];
[image release];
}
问题是什么?
I have this method for button click (download). The problem is that it is terminating due to an exception:
[Session started at 2011-03-14 13:06:45 +0530.] 2011-03-14 13:06:45.710 XML[7079:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString isFileURL]: unrecognized selector sent to instance 0x62b8'
-(IBAction) download
{
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:@"http://ws.cdyne.com/WeatherWS/Images/thunderstorms.gif"]];
[image release];
}
What is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它需要 NSURL 作为参数,而不是字符串。
编辑:
要测试数据是否已成功加载,请尝试类似的操作
It expects an NSURL as argument, not a string.
EDIT:
To test if the data has loaded succesfully try something like
dataWithContentsOfURL
方法采用NSURL
作为参数,而不是NSString
The method
dataWithContentsOfURL
take aNSURL
as argument not aNSString