9 Tips To Maximize Performance Of An iPhone App
Best Practices To Maximize App Performance
Here’s 9 tips that our app developers regularly follow to maximize an app’s performance on the iPhone.
Always use PNG files, they’re optimized at build time by Xcode to be more compact and faster to load.
Use plists over XML. They’re much smaller (optimized by Xcode to be compact binaries and don’t need to be parsed at runtime) and faster (XML parsers are very expensive).
Avoid auto-released objects whenever possible. Avoid utility methods like +stringWithFormat, instead use direct allocation (-initWithFormat:). When many auto-released objects are needed in a context, create local release pools.
Non atomic properties are 10x faster to read and write.
Calling [super didReceiveMemoryWarning] when implementing the -didReceiveMemoryWarning memory is very very important.
When implementing a custom -drawRect method, it’s very important to set the view as opaque (since alpha drawing is very expensive). It’s also important to define the area to redraw using CGRect and really only redraw that part of the view.
Avoid allocating objects in the scrolling callback methods (UITableView and UIScrollView delegates).
Don’t forget to reuse table cells. When a customized table cell is needed, to make the scrolling smooth, try to create a flat view hierarchy or better than that, make the cell use -drawRect (using -drawText and -drawImage). Custom drawing is the most optimized way to make table cells with complex layouts.
To access large files, use memory mapping. See [NSData initWithContentOfMappedFile:].