简体   繁体   中英

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

I tried 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM