iOS removeFromSuperview if not added to superview doesn't throw an error
I tried开发者_JAVA技巧 removeFromSuperview
on a view that had not been added as a subview but Xcode 4 didn't throw any error. Is this expected behaviour?
First off, Xcode 4 wouldn't do anything at all. That's the IDE. It has nothing to do with the runtime behavior of your app.
Secondly, the documentation for -removeFromSuperview
states
If the receiver’s superview is not nil, the superview releases the receiver.
What part of this would lead you to expect -removeFromSuperview
to throw an exception if the view has no superview?
In any case, the answer is yes, this is normal. -removeFromSuperview
does not throw exceptions.
精彩评论