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.
I think you are using NSString
as NSURL
. Try this:
NSURL *imageUrl =[NSURL URLWithString:[attributeDict objectForKey:@"url"]];
It looks like "url" is in fact an NSString
, not an NSURL
object. Convert it to an NSURL
object yourself:
if ([elementName isEqualToString:IMAGE])
{
NSString *urlStr = [attributeDict objectForKey:@"url"];
NSURL *imageUrl = [NSURL URLWithString:urlStr];
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
bbc.image = [UIImage imageWithData:imageData];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With