-2

I have successfully parsed XML data into my iOS application so now it displays all the most recent blog posts, however I need help on how to access the thumbnail images from the xml files. You can use this link to better see where the image is stored

http://www.autoblog.com/rss.xml

I'm guessing you need to request the data for the url then create an image with the data, but just need an example to help me out.

I greatly appreciate any sort of help that you can offer me.

  • Show what you have tried and better explain the part of the code you need help with. – rmaddy Jul 09 '14 at 04:32
  • You should also do [some searching](http://stackoverflow.com/search?q=%5Bios%5D+xml+image). – rmaddy Jul 09 '14 at 04:34
  • I can't see images in the xml tags as such, but they are there in the data, may be you want to extract thumb from data? – iphonic Jul 09 '14 at 05:01

2 Answers2

0

The basic is simple.

NSString *imageURL = @"http://~~~~";
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]];
UIImage *image = [UIImage imageWithData:data];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

But you have to concern many things related with network. Why don't you use AFNetworking? It's very useful framework. There's a category to handle this kind of thing.

Ryan
  • 4,799
  • 1
  • 29
  • 56
0

To show the thumbnails, I would use an UICollectionView and a custom cell with an embedded UIImageView. Implement the UICollectionViewDataSource protocol and do the network stuff in cellForItemAtIndexPath method. This way, it only gets the thumbnail when needed.

AFNetworking also simplifies a lot.

Here is an example using tableviews and Flickr APIs http://iosdevelopertips.com/networking/iphone-json-flickr-tutorial-part-1.html

SauloT
  • 153
  • 7