0

I'm using RestKit in my project, and was wondering the best way to pull images from the JSON into the UITableView cells.

JSON response:

{
    "timestamp": "2013-05-10T03:09:39Z",
    "resultsOffset": 0,
    "status": "success",
    "resultsLimit": 10,
    "breakingNews": [],
    "resultsCount": 393,
    "feed": [{
        "headline": "Headline text",
        "lastModified": "2013-05-08T14:55:03Z",
        "description": "Description text.",
        "images": [{
            "height": 324,
            "alt": "",
            "width": 576,
            "name": "The Name",
            "caption": "Debate it.",
            "url": "http://a.website.com/media/motion/2013/0508/dm_130508_debate/dm_130508_debate.jpg"
        }],

Is there a good way in RestKit to do it, or should I use AFNetworking, or is some other way better?

I can post extra code snippets on how I already am pulling the headline/description/lastModified. I have a Feed model set up right now for that. From what I can understand, getting the image url is slightly different tho.

Need... enter image description here

... to have Image enter image description here

Realinstomp
  • 532
  • 2
  • 13
  • 30
  • http://stackoverflow.com/questions/1130089/lazy-load-images-in-uitableview?lq=1 – Thilo May 10 '13 at 03:31
  • AFNetworking and UIImageWeb both have UIImageView categories for asynchronous loading of images. – Rob May 10 '13 at 03:32
  • @Rob Thanks for the quick response! Have a recommendation on which one is easier to use in your experience? – Realinstomp May 10 '13 at 03:37
  • @Thilo Thanks for the link, I think I've come across that before and I'll look into using it since it seems like alot of people use it. If you have any personal experience and have a specific recommendation too let me know. Thx! – Realinstomp May 10 '13 at 03:38
  • @Rob Awesome, thanks for the detailed suggestion, appreciate it! – Realinstomp May 10 '13 at 15:10
  • @Reez. They're both one line calls to UIImageView categories. As seamless as painless as can be. `AFNetworking` is more of a generalized networking solution, and `SDWebImage` is more special purpose solution. (And in a correction to my earlier comment, both handle caches well.) But given that you're using `RESTKit` (and therefore don't need most of AFNetworking), perhaps `SDWebImage`'s focus on image processing, maybe that's a more logical choice. – Rob May 10 '13 at 15:22
  • @Rob Cool, I am trying out `SDWebImage` right now, thanks! – Realinstomp May 10 '13 at 17:00

2 Answers2

1

you can use async imageview which will the display the image from URL, you can use the following https://github.com/enormego/EGOImageLoading/tree/master/EGOImageView

Manish Agrawal
  • 10,958
  • 6
  • 44
  • 76
1

Try using SDWebImage for Asynchronous download and cache images. It works perfect for me.

Community
  • 1
  • 1
Khawar
  • 9,151
  • 9
  • 46
  • 67