ibireme / YYImage

Image framework for iOS to display/encode/decode animated WebP, APNG, GIF, and more.
MIT License
1.76k stars 479 forks source link

Subclassing YYImage #158

Open GiuseppePiscopo opened 3 years ago

GiuseppePiscopo commented 3 years ago

Hello all, hope there's still someone reading this. In a number of issues the answerer suggests to solve problem by subclassing YYImage, eg. #1 , #36 , #146 .

Say that MyImage is the subclass name. The point is that, as soon as one tries to invoke MyImage(named: "whatever"), you get into typical errors of missing initializers in subclass.

Q1: Why does every suggestion completely misses to mention that? Maybe there's something wrong we're doing and I'm missing something evident.

Q2: We'd like to avoid duplicating code from YYImage class factory methods like:

+ (YYImage *)imageNamed:(NSString *)name

or from initializers:

- (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale

but then there seems to be no way to invoke those from the subclass initializer, at least not from Swift.