SDImageCodersManager

@interface SDImageCodersManager : NSObject <SDImageCoder>

Global object holding the array of coders, so that we avoid passing them from object to object. Uses a priority queue behind scenes, which means the latest added coders have the highest priority. This is done so when encoding/decoding something, we go through the list and ask each coder if they can handle the current data. That way, users can add their custom coders while preserving our existing prebuilt ones

Note: the coders getter will return the coders in their reversed order Example:

  • by default we internally set coders = IOCoder, GIFCoder, APNGCoder
  • calling coders will return @[IOCoder, GIFCoder, APNGCoder]
  • call [addCoder:[MyCrazyCoder new]]
  • calling coders now returns @[IOCoder, GIFCoder, APNGCoder, MyCrazyCoder]

Coders

A coder must conform to the SDImageCoder protocol or even to SDProgressiveImageCoder if it supports progressive decoding Conformance is important because that way, they will implement canDecodeFromData or canEncodeToFormat Those methods are called on each coder in the array (using the priority order) until one of them returns YES. That means that coder can decode that data / encode to that format

  • Returns the global shared coders manager instance.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nonnull, class) SDImageCodersManager *sharedManager;

    Swift

    class var shared: SDImageCodersManager { get }
  • All coders in coders manager. The coders array is a priority queue, which means the later added coder will have the highest priority

    Declaration

    Objective-C

    @property (copy, nonatomic, nullable) NSArray<id<SDImageCoder>> *coders;

    Swift

    var coders: [SDImageCoder]? { get set }
  • Add a new coder to the end of coders array. Which has the highest priority.

    Declaration

    Objective-C

    - (void)addCoder:(nonnull id<SDImageCoder>)coder;

    Swift

    func addCoder(_ coder: SDImageCoder)

    Parameters

    coder

    coder

  • Remove a coder in the coders array.

    Declaration

    Objective-C

    - (void)removeCoder:(nonnull id<SDImageCoder>)coder;

    Swift

    func removeCoder(_ coder: SDImageCoder)

    Parameters

    coder

    coder