What is the correct way to remove a view from it if it is no longer needed?
This warning exists, so you don't call removeFromSuperview
from a method drawRect:
. The Cocoa runtime makes extensive use of the view hierarchy during drawing operations, so removing a view from its supervisor while drawing can really hurt.
Calling removeFromSuperview
at any other time is perfectly fine and there is no need to hide the view until it is deleted.
source to share
Wow. I have never seen this note in the docs before and I just got a little scared of the code I wrote :)
The consensus is that this is a poorly worded proposal and you shouldn't call this method while displaying / drawing something. But if it is currently displayed, then that's okay.
I would recommend contacting Apple for advice on this.
source to share