Suppose you have a tableview that you can refresh. Would you keep the activityAnimator in memory or re-create it every time you click on refresh?
I know this could sound pretty obvious, it seems pretty clear that in the first case you get to speed up your app and in the other case you get to have more free memory space.
But I was wondering whether one of the two was closer to “Apple standards”.
Which one is more important? CPU use or memory use?
And don’t tell me it depends on what I need to do.
By “activityAnimator” I assume you mean
UIActivityIndicatorView.If that is the case, you should add the indicator via Interface Builder, and connect it to your view controller. This means if the controller is not top most, the OS can release the connected objects, including the indicator if required. It also means you don’t have to create and destroy it each time you use it. Best of both worlds.
Having said that, this feels like premature optimisation. I would imagine the datasource backing your table view would take up much more memory that what a
UIActivityIndicatorViewwill. I suggest setting upUIActivityIndicatorViewin IB and use it.