Search code examples
objective-ciosxcodeios5ios4

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


I am new to iPhone App development.

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 -

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

It is occurring only when I try to display the image in UITableViewCell.

The code I used for getting images from url is -

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.


Solution

  • I think you are using NSString as NSURL. Try this:

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