开发者

iOS removeFromSuperview if not added to superview doesn't throw an error

开发者 https://www.devze.com 2023-03-16 09:15 出处:网络
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 al

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号