“This is the fifth day of my participation in the First Challenge 2022. For details: First Challenge 2022.”
Beginner performance boost
This section focuses on some basic changes that can improve performance. But all developers are likely to ignore some of the advice in this section.
1. Use ARC to manage memory
ARC(Automatic Reference Counting) comes with iOS5, which avoids the most common memory leak that often happens when we forget to free memory. It automatically manages the retain and release process for you, so you don’t have to manually intervene.
In addition to helping you avoid memory leaks, ARC can also help you improve performance by ensuring that you free up memory for objects no longer needed.
Here are some resources to learn more about ARC:
1 > Apple’s official documentation
Matthijs Hollemans’ Beginning ARC in iOS Tutorial
3> Tony Dahbura’s How To Enable ARC in a Cocos2D 2.X Project
4> If you still aren’t convinced of the benefits of ARC, check out this article on eight myths about ARC to really convince you why you should be using it.
ARC certainly can’t rule out all memory leaks for you. Memory leaks can still occur due to blocking, retain cycles, poorly managed CoreFoundation Objects (and C structures), or simply bad code. An article on what ARC can’t do and what we can do about it.
2. Use reuseIdentifier in the right place
In developing a common mistake is not to UITableViewCells UICollectionViewCells, even UITableViewHeaderFooterViews reuseIdentifier set up correctly.
For performance optimization, the table view with a tableView: cellForRowAtIndexPath: proxy method for the distribution of rows of cells, its data should reuse self UITableViewCell. A table view maintains a queue of data reusable UITableViewCell objects.
Without the reuseIdentifier, you would have to set a new cell for each row of table View displayed. This can have a significant impact on performance, especially the scrolling experience of the app. As of iOS6, in addition to UICollectionView cells and supplementary views, you should also use reuseIdentifiers in header and footer views.
3. Make Views as transparent as possible
If you have Views that are transparent you should set their opaque property to YES. This will enable the system to render these views in an optimal way. This simple property can be set either in IB or in code.
The Apple documentation for setting the transparency property for an image says :(opaque) this property gives the rendering system a clue as to what to do with the view. If set to YES, the rendering system considers the view to be completely opaque, which allows the rendering system to optimize some of the rendering process and improve performance. If set to NO, the rendering system normally makes up the View with other content. The default value is YES.
On relatively still screens, setting this property does not have much effect. However, if the view is embedded in the Scroll View or is part of a complex animation, not setting this property will greatly affect the performance of the APP.
You can use the Debug- >Color Blended Layers option in the emulator to find out which views are not set to Opaque. And the goal is, if you can make it opaque, make it opaque.