iOS - Asynchronous Image Downloading

2019-02-21 00:33发布

I am writing an app which is going to be displaying images found on my server in a UIImageView.

I need something that will asynchronously download the image and cache it while putting it in the UIImageView. The download also needs to be able to be cancelled when I press a button.

Can anyone point me in the direction of something that can do this?

2条回答
女痞
2楼-- · 2019-02-21 01:01

Use the performSelectorInBackground:withObject: - method from NSObject ;)

Advise: The updating of the view must run on the main thread!

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsobject_Class/Reference/Reference.html

查看更多
一纸荒年 Trace。
3楼-- · 2019-02-21 01:07

In the old times the framework for that was ASIHTTPRequest but is an abandoned project now. This https://github.com/AFNetworking/AFNetworking seems to be popular now.

查看更多
登录 后发表回答