-
-
Notifications
You must be signed in to change notification settings - Fork 6k
5.0 Migration guide
SDWebImage 5.0 is the latest major release of SDWebImage, a top library for downloading and caching images. As a major release, following Semantic Versioning conventions, 5.0 introduces several API-breaking changes with its new architecture.
This guide is provided in order to ease the transition of existing applications using SDWebImage 4.X to the latest APIs, as well as explain the design and structure of new and changed functionality.
SDWebImage 5.0 officially supports iOS 8 and later, Mac OS X 10.10 and later, watchOS 2 and later and tvOS 9 and later. It needs Xcode 9 or later to be able to build everything properly.
For targeting previous versions of the SDKs, check README - Backwards compatibility .
- TBD if needed -
- TBD if needed -
We are no longer hosting the integration with FLAnimatedImage inside this repo. We have a dedicated repo for that.
TBD
- new initializer
initWithNamespace:diskCacheDirectory:config:, is now the designated initializer - moved
maxMemoryCostandmaxMemoryCountLimittoSDImageCacheConfig - added
SDImageCache diskImageDataExistsWithKey:synchronous method -
addReadOnlyCachePath:removed, useadditionalCachePathBlockinstead -
cachePathForKey:inPath:removed, usecachePathForKey:with NSString's path API instead. -
defaultCachePathForKey:removed, usecachePathForKey:instead
- added
diskCacheWritingOptionsof typeNSDataWritingOptions, defaults toNSDataWritingAtomic - added
maxMemoryCostandmaxMemoryCountLimitproperties (used to be inSDImageCache) -
shouldDecompressImagesremoved. UseSDImageCacheAvoidDecodeImagein cache options instead
-
loadImageWithURL:options:progress:completed:changed thecompletedparam requirement fromnullabletononnull -
loadImageWithURL:options:progress:completed:return typeid<SDWebImageOperation>changed toSDWebImageCombinedOperation * -
shared()changed toshared -
isRunning()changed toisRunning -
imageCachechanged from nullable to nonnull -
imageDownloaderrenamed toimageLoaderand changed from nullable to nonnull -
cacheKeyFilterproperty type changed toid<SDWebImageCacheKeyFilter>, use theSDWebImageCacheKeyFilter cacheKeyFilterWithBlock: -
cacheSerializerproperty type CHANGED toid<SDWebImageCacheSerializer>, use theSDWebImageCacheSerializer cacheSerializerWithBlock: -
imageCacheproperty type changed fromSDImageCache *toid<SDImageCache>. The default value does not change. -
initWithCache:downloader:'scachearg type changed fromSDImageCache *toid<SDImageCache> -
initWithCache:downloaderrenamed toinitWithCache:loader: -
saveImageToCache:forURL:removed. UseSDImageCache storeImage:imageData:forKey:cacheType:completion:(orSDImageCache storeImage:forKey:toDisk:completion:if you use default cache class) withcacheKeyForURL:instead. -
diskImageExistsForURL:completion:removed. UseSDImageCache containsImageForKey:cacheType:completion:(orSDImageCache diskImageExistsWithKey:completion:if you use default cache class) withcacheKeyForURL:instead. -
cachedImageExistsForURL:completionremoved. UseSDImageCache containsImageForKey:cacheType:completion:(orSDImageCache diskImageExistsWithKey:completion:andSDImageCache imageFromMemoryCacheForKey:if you use default cache class) withcacheKeyForURL:instead.
- removed
imageManager:transformDownloadedImage:forKey:
-
sd_internalSetImageWithURL:placeholderImage:options:operationKey:setImageBlock:progress:completed:renamed toUIView sd_internalSetImageWithURL:placeholderImage:options:context:setImageBlock:progress:completed:(The biggest changes is that the completion block type fromSDExternalCompletionBlocktoSDInternalCompletionBlock. Which allow advanced user to get more information of image loading process) -
sd_internalSetImageWithURL:placeholderImage:options:operationKey:setImageBlock:progress:completed:context:removed - activity indicator refactoring - use
sd_imageIndicatorwithSDWebImageActivityIndicator-
sd_setShowActivityIndicatorView:removed -
sd_setIndicatorStyle:removed -
sd_showActivityIndicatorViewremoved -
sd_addActivityIndicator:removed -
sd_removeActivityIndicator:removed
-
- Renamed
isGIFtosd_isAnimated, alsoNSImage isGIFrenamed toNSImage sd_isAnimated - Renamed
decodedImageWithImage:tosd_decodedImageWithImage: - Renamed
decodedAndScaledDownImageWithImage:tosd_decodedAndScaledDownImageWithImage: - Removed
sd_webpLoopCountsince we havesd_imageLoopCount
- Removed
sd_setImageWithPreviousCachedImageWithURL:placeholderImage:options:progress:completed
-
shared()changed toshared -
setOperationClassavailable for Swift user -
setSuspended(_:)changed toisSuspendedproperty -
shouldDecompressImagesmoved toSDWebImageDownloaderConfig.shouldDecompressImages -
maxConcurrentDownloadsmoved toSDWebImageDownloaderConfig.maxConcurrentDownloads -
downloadTimeoutmoved toSDWebImageDownloaderConfig.downloadTimeout -
operationClassmoved toSDWebImageDownloaderConfig.operationClass -
executionOrdermoved toSDWebImageDownloaderConfig.executionOrder -
urlCredentialmoved toSDWebImageDownloaderConfig.urlCredential -
usernamemoved toSDWebImageDownloaderConfig.username -
passwordmoved toSDWebImageDownloaderConfig.password -
initWithSessionConfiguration:removed, useinitWithConfig:]with session configuration instead -
createNewSessionWithConfiguration:removed, useinitWithConfig:]with new session configuration instead. To modify shared downloader configuration, provide customSDWebImageDownloaderConfig.defaultDownloaderConfigbefore it created. -
headersFilterremoved, userequestModifierinstead -
cancel:removed, useSDWebImageDownloadToken cancelinstead -
shouldDecompressImagesremoved. UseSDWebImageDownloaderAvoidDecodeImagein downloader options instead - use
SDWebImageLoaderProgressBlockinstead ofSDWebImageDownloaderProgressBlock - use
SDWebImageLoaderCompletedBlockinstead ofSDWebImageDownloaderCompletedBlock
-
initWithRequest:inSession:options:context:is now the designated initializer - Removed
shouldUseCredentialStorageproperty -
SDWebImageDownloadOperationInterfaceprotocol renamed toSDWebImageDownloadOperation. (SDWebImageDownloadOperationProtocolfor Swift) -
expectedSizeremoved, useresponse.expectedContentLengthinstead -
shouldDecompressImagesremoved. UseSDWebImageDownloaderAvoidDecodeImagein downloader options instead.
-
prefetchURLs:andprefetchURLs:progress:completed:return types changed fromvoidtoSDWebImagePrefetchToken -
prefetcherQueueproperty renamed todelegateQueue -
maxConcurrentDownloadsproperty removed, useSDWebImageManager.downloaderconfig instead
-
SDCGColorSpaceGetDeviceRGB()moved toSDImageCoderHelper colorSpaceGetDeviceRGB -
SDCGImageRefContainsAlpha(), moved toSDImageCoderHelper imageRefContainsAlpha: -
decodedImageWithData:replaced withdecodedImageWithData:options: -
encodedDataWithImage:format:replaced withencodedDataWithImage:format:options -
initmethod fromSDWebImageProgressiveCoderchanged toinitIncrementalWithOptions: -
incrementalDecodedImageWithData:finishedreplaced withupdateIncrementalData:finishedandincrementalDecodedImageWithOptions: - removed
decompressedImage:data:options
-
sharedInstance()changed toshared
-
shared()changed toshared
-
shared()changed toshared
-
shared()changed toshared
-
sd_UTTypeFromSDImageFormatreturnCFStringinstead ofUnmanaged<CFString>
-
sd_currentImageURL()changed tosd_currentImageURL
-
sd_currentImageURL()changed tosd_currentImageURL -
sd_currentAlternateImageURL()changed tosd_currentAlternateImageURL
-
SDWebImageInternalSetImageGroupKeyrenamed toSDWebImageContextSetImageGroup -
SDWebImageExternalCustomManagerKeyrenamed toSDWebImageContextCustomManager