In iOS, objective-C uses reference counting to manage memory. Recently, when writing animation effects, it encountered a memory leakage problem.
For the delegate declaration of objects, we recommend that you use assign in the objective-C Programming Guide. If you use retain to add the declaration method of reference count, improper management can easily lead to loop reference problems, resulting in the memory cannot be released. However, this write animation finds an exception, that is, when the value of the cabasicanimation delegate value is assigned, the reference count of the object is increased by one. When the removeoncompletion of cabasicanimation is no, the animation will not be removed after the animation ends. A circular reference is formed and the object cannot be released. Do not set the removeoncompletion of an animation to no after the delegate of the animation is specified. When you are not sure whether the animation is completed, it is best to call the removeanimationforkey method of calayer to manually remove the animation. Refer to the delegate of cabasicanimation.
About the delayed execution method-(void) performselector :( SEL) aselector withobject :( ID) anargument afterdelay :( nstimerinterval) delay; During the call, the reference count of the nsobject that calls it is also added to 1, before releasing the memory, call the corresponding + (void) cancelpreviousperformrequestswithtarget :( ID) atarget; Method to clear requests in the queue.