WebASDKImageManager

by ide

Image downloader and cache for AsyncDisplayKit that uses SDWebImage

124 Stars 20 Forks Last release: over 5 years ago (1.0.1) MIT License 23 Commits 6 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

WebASDKImageManager

Version License Platform

Notice

AsyncDisplayKit now uses Pinterest's PINRemoteImage and PINCache if you include them as dependencies. They provide the functionality that WebASDKImageManager originally set to provide and manage memory more efficiently because they work more tightly with AsyncDisplayKit. Unless you specifically wish to use SDWebImage, you should use AsyncDisplayKit's default functionality.


An image downloader and cache for AsyncDisplayKit that uses SDWebImage. This is an implementation of

ASImageDownloaderProtocol
and
ASImageCacheProtocol
that is compatible with
ASNetworkImageNode
.

By default,

ASNetworkImageNode
does not cache images and does not coalesce network requests for the same image. SDWebImage does both of these. With WebASDKImageManager, you get the image downloading and caching optimizations of SDWebImage and the asynchronous layout and layer precompositing features of ASDK.

Installation

WebASDKImageManager is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "WebASDKImageManager"

Usage

The easiest way to use WebASDKImageManager is an initializer it provides in a category on

ASNetworkImageNode
.
ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] initWithWebImage];
// Setting the URL property will automatically access the memory and disk
// caches, and download and cache the image if necessary
imageNode.URL = imageURL;

Configuration

By default, image downloading and caching is handled by a shared

WebASDKImageManager
instance. You can get a reference to the shared manager by calling
[SDWebASDKImageManager sharedManager]
. Its
webImageOptions
property is the way to configure the downloading and caching behavior for all ASNetworkImageNode instances that used the shared manager.
SDWebASDKImageManager *defaultManager = [SDWebASDKImageManager sharedManager];
// No longer try to download images that were previously unavailable
defaultManager.webImageOptions &= ~SDWebImageRetryFailed;

Defaults

The default options are

SDWebImageRetryFailed
and
SDWebImageContinueInBackground
, which are generally what you want. See SDWebImage's
SDWebImageOptions
enum for all of the supported options.

Configuring a Single Image Node

Sometimes you may want to configure an image node differently than the default. You can do this by creating a new

WebASDKImageManager
that is configured to meet your needs.
SDWebImageManager *webImageManager = [SDWebImageManager sharedManager];
SDWebASDKImageManager *asyncImageManager =
  [[SDWebASDKImageManager alloc] initWithWebImageManager:webImageManager];
asyncImageManager.webImageOptions = SDWebImageRetryFailed | SDWebImageCacheMemoryOnly;

WebASDKImageManager
conforms to
ASImageDownloaderProtocol
and
ASImageCacheProtocol
, so you can use your new manager to create a new image node.
ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] initWithCache:asyncImageManager 
                                                               downloader:asyncImageManager];

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.