SKNode has a removeChild undocumented method which is called on parent object when deleting its child by removeFromParent method. Is it safe to override removeChild?
1 Answers
Probably yes, but no.
The problem is you don't know whether this method will be called in all instances. For example I noticed some SK*Node classes route some messages directly to the underlying C++ objects rather than passing the message on to the super implementation in SKNode.
Furthermore I wager that overriding a private method constitutes a case of private API use that might get your app barred from publishing on the App Store.
Technically though just try it and see if it works. It probably will. But for all other reasons you certainly shouldn't do it.
Instead override removeFromParent
and access self.parent
in your override in case you need to do something with the parent. Note that you will have to do this in every SK*Node subclass. This is because you can't override a method in a category, and you can't subclass SKNode and expect the subclass methods to be called from other SKNode direct subclasses such as SKSpriteNode (because they are parallel to your subclass, not a subclass of your SKNode subclass).

- 64,284
- 20
- 132
- 217