Monday, 15 February 2010

ios - Good practice loading UIImage -


There are some icons in my app that I reuse in several views (for example a favorite icon).

To save memory, I was wondering if using a class with class messages that loads static images would be a good idea?

For example:

  + (UIImage *) Favorites icon {Fixed UIImage * icon; If (! Icon) icon = [UIImage imageNamed: @ "favorite .png"]; Return icon; }   

Or should I just use the + (UIImage *) nameNamed: (NSString *) name every time I need it?

Thanks for your advice.

[UIImage imageNamed:] is already doing something hood Actually, it's smart, because it is doing things like dumping images when the memory is low and they are not needed immediately, while your preferred icon method fills them forever Happens

In general, it would be better to avoid optimization, unless you have not prepared your app and then have a profile to see how / where it needs correction otherwise you will waste time Whether or even doing things worse, I advise you how to use your app to use instruments, it is very complicated, but it has been a lot of fun You let him hang.

No comments:

Post a Comment