I want the apps I build to be lightning fast.
What tech开发者_Go百科niques should I use to ensure that my apps stay fast and responsive?
Do as little as possible in the main thread. Use NSOperations / GCD and other Background Techniques to load everything off the main thread. And what everybody else said :)
Your question is a general one, but the answer is "Memory Management".
All of the answers provided so far all fall into this category. Whether you're playing media (video, audio, photo) or showing data (using UITableView), you want to optimize for low memory.
The trick is to load only what you need and nothing more at any given time.
Also, GCD.
Don't use large images / videos / audio files, or init alot of objects that are not actively being used, and release when possible.
If you're using a UITableView, make sure you prepare all your data beforehand and simply grab it from the relevant model class instance within your tableView:cellForRowAtIndexPath: delegate method - to do otherwise will kill the responsiveness.
Additionally, do the right thing and make sure you use the dequeueReusableCellWithIdentifier method in the provided UITableView.
Profile all methods and functions that run in the main UI thread, and make sure that they all (including subroutines and delegates) take less than 16 milliseconds max to completely exit to the run loop. Make sure all your UI drawing updates, together with these UI methods, also take less than 16 mS max. Then your UI can run at 60 fps (which is the max possible on current devices), and is unlikely to miss any input events.
Everything else, all image loads, all network data transfers, all processing, etc., run async and/or in a background thread.
(And what everybody else said as well... :)
Use core data as much as possible. I never saw a case where using core data is worst than using another method.
精彩评论