Monday, October 18, 2010

Basic Note on UIImage

UIImage
Its a wrapper to the existing CGImage class. CG refers to core graphics and is basically C API's with whole lot of features.

- In the case of imageNamed: method the image is actually cached by the OS .All the subsequent calls will return the cached image. However with imageWithContentsOfFile: method the image is lazily loaded on demand.Lazy loading is one of the key point to be considered for better performance.

Relevance:
- Avoid loading many images at once, particularly in the applicationDidFinishLaunching: or viewDidLoad: method. This can slow down the application or the view that is to be loaded.
- Iphone OS itself uses the imageNamed: to load the images from the NIB

When to use imageWithContentsOfFile:
- Any image that is not needed immediately
- images used infrequently or rarely. This is to avoid the OS caching images that are not used frequently in turn not pressurizing OS cache.

No comments:

Post a Comment