Is it safe to call [n removeFromParent];
after the parent to n
has been released (and thus does not exist)?
I guess n.parent
will be nil
at that point.
Do I have to do something like
if (n.parent != nil)
[n removeFromParent];
For reference:
Yes, I do it all the time. If you want to validate, simply do something like this the next time you call want to do it.
[n removeFromParent];
[n removeFromParent];
[n removeFromParent];
[n removeFromParent];
You'll notice no side effects.
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.