iOS - Caching and loading images asynchronously

后端 未结 3 446
醉酒成梦
醉酒成梦 2020-12-12 12:34

I want an image loading and caching library for iOS that

  • loads images asynchronously,
  • caches images, with a configurable cache size and LRU behaviour,
3条回答
  •  不知归路
    2020-12-12 13:20

    EDIT : ASI has been deprecated now but @Tony's answer has a link to a library that seems to do most of this (disclaimer - I've not yet tried it and am going by @Tony's recommendation!)


    ASIHTTPRequest does all of that :)

    All you would have to do is add something like to the success callback

    UIImage *image = [UIImage imageWithData:[request responseData]];
    
    // If the image is nil ASIHTTPRequest will let you remove the data from the cache
    // but I can't remember off the top of my head how. Checkout the docs!
    

    EDIT

    And when you've finished it, you could always pop it onto github for the rest of us . . .

提交回复
热议问题