简体   繁体   English

NSInvalidArgumentException',原因:' - [__ NSCFString isFileURL]:无法识别的选择器发送到实例0x712e450'

[英]NSInvalidArgumentException', reason: '-[__NSCFString isFileURL]: unrecognized selector sent to instance 0x712e450'

I am new to iPhone App development. 我是iPhone App开发的新手。

When I run a sample project, I did which parses an xml feed and displays the contents along with image in a table view, I get this error - 当我运行一个示例项目时,我做了解析xml提要并在表视图中显示内容和图像,我收到此错误 -

"NSInvalidArgumentException', reason: '-[__NSCFString isFileURL]: unrecognized selector sent to instance 0x712e450'"

It is occurring only when I try to display the image in UITableViewCell . 它只在我尝试在UITableViewCell显示图像时才会发生。

The code I used for getting images from url is - 我用来从url获取图片的代码是 -

if([elementName isEqualToString:IMAGE])
{
    NSURL *imageUrl = [attributeDict objectForKey:@"url"];
    NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
    bbc.image = [UIImage imageWithData:imageData];        
}

where bbc is a class(NSObject subclass) object used to store the parsed contents. 其中bbc是用于存储已解析内容的class(NSObject subclass)对象。

I think you are using NSString as NSURL . 我认为你使用NSString作为NSURL Try this: 试试这个:

    NSURL *imageUrl =[NSURL URLWithString:[attributeDict objectForKey:@"url"]];

It looks like "url" is in fact an NSString , not an NSURL object. 看起来“url”实际上是NSString ,而不是NSURL对象。 Convert it to an NSURL object yourself: 自己将其转换为NSURL对象:

if ([elementName isEqualToString:IMAGE])
{
    NSString *urlStr = [attributeDict objectForKey:@"url"];
    NSURL *imageUrl = [NSURL URLWithString:urlStr];
    NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
    bbc.image = [UIImage imageWithData:imageData];        
}

imageURL不是NSURL,而是字符串。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 终止应用程序-'NSInvalidArgumentException',原因:'-[NSCFString objectForKey:]:无法识别的选择器已发送到实例 - Terminating app - 'NSInvalidArgumentException', reason: '-[NSCFString objectForKey:]: unrecognized selector sent to instance UIPickerView NSInvalidArgumentException',原因:“-[__ NSCFString超级视图]:无法识别的选择器已发送到实例 - UIPickerView NSInvalidArgumentException', reason: '-[__NSCFString superview]: unrecognized selector sent to instance 'NSInvalidArgumentException',原因:'-[__ NSCFString objectAtIndex:]:无法识别的选择器已发送到实例 - 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 'NSInvalidArgumentException',原因:'-[__ NSCFString encodeString:]:无法识别的选择器已发送到实例 - 'NSInvalidArgumentException', reason: '-[__NSCFString encodeString:]: unrecognized selector sent to instance 'NSInvalidArgumentException',原因:'-[__NSCFString allKeys]:无法识别的选择器发送到实例 0x7ae2f750' - 'NSInvalidArgumentException', reason: '-[__NSCFString allKeys]: unrecognized selector sent to instance 0x7ae2f750' NSInvalidArgumentException - [__ NSCFString unsignedLongLongValue]:发送到实例的无法识别的选择器 - NSInvalidArgumentException -[__NSCFString unsignedLongLongValue]: unrecognized selector sent to instance iOS:“ NSInvalidArgumentException”,原因:“-[__ NSCFString sortedArrayUsingFunction:context:]:无法识别的选择器已发送到实例。 - iOS: 'NSInvalidArgumentException', reason: '-[__NSCFString sortedArrayUsingFunction:context:]: unrecognized selector sent to instance. 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:-[__ NSCFString方案]:无法识别的选择器已发送到实例 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: -[__NSCFString scheme]: unrecognized selector sent to instance 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[__ NSCFString size]:无法识别的选择器已发送到实例 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString size]: unrecognized selector sent to instance NSInvalidArgumentException原因:无法识别的选择器发送到实例 - NSInvalidArgumentException reason : unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM