Resource optimization: Start resource files, compress images/audio, remove unnecessary resources
IOS project thin, delete useless pictures, batch compression pictures
Compiler optimization:
The release should be on the slowest, Smalllest option, which will enable all optimizations that do not increase the code size (new Xcode defaults) remove symbol information (all new Xcode defaults)
Executable file optimization:
Check the size of the.o file after the third-party library is compiled. If it has a big impact on the size, you can consider replacing and deleting useless code. If the project lasts for a long time and the code is left behind, it is still more effective (you can use scripts to find classes that are not referenced and methods that are not called).
Memory optimization
- Lazy loading of Views, some resources
- If the server does not update the resource, the client does not need to request a second time, just add the local resource -YYCache
- Autorelease Pool reduces memory spikes
- Image cache
Performance optimization
-
The view is set to opaque to avoid layer blending and consume GPU resources
-
Rounded corners, shadows, rasterization, and overwriting drawrects that result in off-screen rendering should all be avoided
-
For a view with too many layers, use Frame layout. Autolayout performance is significantly lower than Frame layout
-
Reasonable thread, I/O not in the main thread
-
Preprocessing and lazy loading: For visual content, try to load early, and for low-priority tasks, try to load late to improve the user experience
-
Use the right API
-
Understand the difference between imageNamed: and imageWithContentsOfFile: (imageNamed: is good for small images that are loaded repeatedly because the system automatically caches loaded images, imageWithContentsOfFile: only loads images)
-
Choose appropriate containers: arrays, for example, are quick to look up by index, slow to insert and delete, and dictionaries, quick to look up by key
-
Avoid date format conversions: NSDateFormatter is time-consuming, and the preferred method is to use C to do or cache the results of NSDateFormatter
-
TableView optimization
-
Set the appropriate reuseIdentifier to reuse the cell
-
Rounded cell corners to avoid off-screen rendering
-
For fixed height, set rowHight directly to ensure unnecessary height calculations and calls, and for variable cells, estimate row height
-
I’ve seen a third-party framework before: With Runloop, calculations are performed while the page is idle, and obviously calculations should not be performed while the list is sliding. When the UI is not sliding, the default Mode is NSDefaultRunLoopMode. When the user is sliding UIScrollView, RunLoop will switch to UITrackingRunLoopMode to accept sliding gestures and handle sliding events (including deceleration and spring effects), and all other modes (except NSRunLoopCommonModes) will be suspended. To ensure that the sliding event is processed first