Reputation: 24750
If a custom view adds several subviews to itself based on a condition if
, and later a setNeedsDisplay
is called on this view where the condition is no longer true
and thus these subviews are not created, are the "old" subviews automatically released from memory during the drawRect
?
Or, should I worry about checking for the presence of subviews, releasing them, then setNeedsDisplay
?
I guess ultimately my question is about the memory implications of setNeedsDisplay
, if it effectively removes from memory the old view and its subviews and then essentially recreates the view from scratch?
Upvotes: 0
Views: 518
Reputation: 124997
-setNeedsDisplay just sets a flag that says "this view needs to be redrawn." As far as I know, it doesn't retain or release anything, or add or remove any subviews.
I'm not sure what you're trying to do, but it sounds like you're worrying too much. Call -setNeedsDisplay when your app's state has changed in a way that requires a given view to be redrawn. If you subsequently remove that view from your view hierarchy, that shouldn't cause any problem.
Upvotes: 1