Kingfisher Documentation

Class Image​Prefetcher

public class ImagePrefetcher: CustomStringConvertible  

ImagePrefetcher represents a downloading manager for requesting many images via URLs, then caching them. This is useful when you know a list of image resources and want to download them before showing. It also works with some Cocoa prefetching mechanism like table view or collection view prefetchDataSource, to start image downloading and caching before they display on screen.

%161 ImagePrefetcher ImagePrefetcher CustomStringConvertible CustomStringConvertible ImagePrefetcher->CustomStringConvertible

Conforms To

CustomStringConvertible

Initializers

init(urls:​options:​progress​Block:​completion​Handler:​)

public convenience init(
        urls: [URL],
        options: KingfisherOptionsInfo? = nil,
        progressBlock: PrefetcherProgressBlock? = nil,
        completionHandler: PrefetcherCompletionHandler? = nil) 

Creates an image prefetcher with an array of URLs.

The prefetcher should be initiated with a list of prefetching targets. The URLs list is immutable. After you get a valid ImagePrefetcher object, you call start() on it to begin the prefetching process. The images which are already cached will be skipped without downloading again.

Parameters

urls [URL]

The URLs which should be prefetched.

options Kingfisher​Options​Info?

Options could control some behaviors. See KingfisherOptionsInfo for more.

progress​Block Prefetcher​Progress​Block?

Called every time an resource is downloaded, skipped or cancelled.

completion​Handler Prefetcher​Completion​Handler?

Called when the whole prefetching process finished.

init(urls:​options:​completion​Handler:​)

public convenience init(
        urls: [URL],
        options: KingfisherOptionsInfo? = nil,
        completionHandler: PrefetcherCompletionHandler? = nil) 

Creates an image prefetcher with an array of URLs.

The prefetcher should be initiated with a list of prefetching targets. The URLs list is immutable. After you get a valid ImagePrefetcher object, you call start() on it to begin the prefetching process. The images which are already cached will be skipped without downloading again.

Parameters

urls [URL]

The URLs which should be prefetched.

options Kingfisher​Options​Info?

Options could control some behaviors. See KingfisherOptionsInfo for more.

completion​Handler Prefetcher​Completion​Handler?

Called when the whole prefetching process finished.

init(resources:​options:​progress​Block:​completion​Handler:​)

public convenience init(
        resources: [Resource],
        options: KingfisherOptionsInfo? = nil,
        progressBlock: PrefetcherProgressBlock? = nil,
        completionHandler: PrefetcherCompletionHandler? = nil) 

Creates an image prefetcher with an array of resources.

Parameters

resources [Resource]

The resources which should be prefetched. See Resource type for more.

options Kingfisher​Options​Info?

Options could control some behaviors. See KingfisherOptionsInfo for more.

progress​Block Prefetcher​Progress​Block?

Called every time an resource is downloaded, skipped or cancelled.

completion​Handler Prefetcher​Completion​Handler?

Called when the whole prefetching process finished.

init(resources:​options:​completion​Handler:​)

public convenience init(
        resources: [Resource],
        options: KingfisherOptionsInfo? = nil,
        completionHandler: PrefetcherCompletionHandler? = nil) 

Creates an image prefetcher with an array of resources.

Parameters

resources [Resource]

The resources which should be prefetched. See Resource type for more.

options Kingfisher​Options​Info?

Options could control some behaviors. See KingfisherOptionsInfo for more.

completion​Handler Prefetcher​Completion​Handler?

Called when the whole prefetching process finished.

init(sources:​options:​progress​Block:​completion​Handler:​)

public convenience init(sources: [Source],
        options: KingfisherOptionsInfo? = nil,
        progressBlock: PrefetcherSourceProgressBlock? = nil,
        completionHandler: PrefetcherSourceCompletionHandler? = nil) 

Creates an image prefetcher with an array of sources.

Parameters

sources [Source]

The sources which should be prefetched. See Source type for more.

options Kingfisher​Options​Info?

Options could control some behaviors. See KingfisherOptionsInfo for more.

progress​Block Prefetcher​Source​Progress​Block?

Called every time an source fetching successes, fails, is skipped.

completion​Handler Prefetcher​Source​Completion​Handler?

Called when the whole prefetching process finished.

init(sources:​options:​completion​Handler:​)

public convenience init(sources: [Source],
        options: KingfisherOptionsInfo? = nil,
        completionHandler: PrefetcherSourceCompletionHandler? = nil) 

Creates an image prefetcher with an array of sources.

Parameters

sources [Source]

The sources which should be prefetched. See Source type for more.

options Kingfisher​Options​Info?

Options could control some behaviors. See KingfisherOptionsInfo for more.

completion​Handler Prefetcher​Source​Completion​Handler?

Called when the whole prefetching process finished.

Properties

description

public var description: String  

max​Concurrent​Downloads

public var maxConcurrentDownloads = 5

The maximum concurrent downloads to use when prefetching images. Default is 5.

Methods

start()

public func start()  

Starts to download the resources and cache them. This can be useful for background downloading of assets that are required for later use in an app. This code will not try and update any UI with the results of the process.

stop()

public func stop()  

Stops current downloading progress, and cancel any future prefetching activity that might be occuring.