[英]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.我在尚未添加为子视图的视图上尝试了removeFromSuperview
,但 Xcode 4 没有引发任何错误。 Is this expected behaviour?这是预期的行为吗?
First off, Xcode 4 wouldn't do anything at all.首先, Xcode 4 根本不会做任何事情。 That's the IDE.那就是 IDE。 It has nothing to do with the runtime behavior of your app.它与您的应用程序的运行时行为无关。
Secondly, the documentation for -removeFromSuperview
states其次, -removeFromSuperview
状态的文档
If the receiver's superview is not nil, the superview releases the receiver.如果接收者的 superview 不为零,则 superview 释放接收者。
What part of this would lead you to expect -removeFromSuperview
to throw an exception if the view has no superview?如果视图没有超级视图,这其中的哪一部分会导致您期望-removeFromSuperview
抛出异常?
In any case, the answer is yes, this is normal.无论如何,答案是肯定的,这很正常。 -removeFromSuperview
does not throw exceptions. -removeFromSuperview
不会抛出异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.