Peter Warbo
Peter Warbo

Reputation: 11700

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?

Upvotes: 1

Views: 2080

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185681

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.

Upvotes: 3

Related Questions