Recommendations for defining FastImageCache FICImageFormats?

I use the Path library FastImageCache( https://github.com/path/FastImageCache ) to make ready-made cache copies ready for use in UIImageViews.

To use FIC, you define FICImageFormatwhich includes a bunch of data, including image size. For maximum performance, this image size should be identical to the size UIImageViewin which the image will be used.

This leads to a chicken and egg problem: should the code that installs FIC (in AppDelegateor wherever you do the main init work for your application, presumably?) Know the dimensions UIImageViewin the rest of your application? This has the obvious drawback of having a very tight connection between your application launch code and user interface implementation details.

An alternative is that you could use your user interfaces for a protocol that defines a method, e.g.

+(NSArray *)imageFormats;

which will return an array of objects FICImageFormatrepresenting all the image formats that this user interface bit will require. Then the startup code only needs to know which classes implement this protocol in order to get a complete list of image formats needed for the application.

This second approach has the disadvantage of a potential duplicate FICImageFormats. It would not be optimal to have two (or more!) Image formats for the same family of image formats, which also have the same size. Then you will cache the same data more than once.

Any other approaches you can think of? Best practics? All thoughts are welcome!

+4
source share
1

, - , .

, AppDelegate "", , , , . , .

0

Source: https://habr.com/ru/post/1530493/


All Articles