UIAcivityIndicatorView stops the animation on its own if it is deleted / freed / freed

I am using UIActivityIndicator in an accessory table table. This is actually a subtitle of anotherView (which is a cellView element), as shown below:

UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] 
    initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[anotherView addSubview:activityIndicator];
[activityIndicator startAnimating];
[activityIndicator release];
cell.accessoryView = anotherView;

In my use case, I no longer need to access the indicator view. Also, if the full view is deleted (due to the rejection of the ViewController), I don't care about these UIActivityIndicators.

So will this use be safe and not create any memory / resources? I checked that deallocfrom UIActivityIndicatorViewis being called (and it is), so I would assume that the animation would be automatically stopped / deleted and the view hierarchy would be destroyed.

Is my assumption correct?

+3
source share
1 answer

Yes, if you give up ownership of the indicator, the hierarchy of views remains the sole owner. If the supervisor is removed from the presentation hierarchy and if it is not saved elsewhere, the supervisor releases all of its children. If the subclauses have reached zero, they are freed. This is what happens to your indicator.

+4
source

All Articles