Search code examples
objective-cinheritancesubclasssuperclass

Can I change the super of a class?


Is it somehow possible to choose the super of a class (preferably in the alloc or init method) so my class inherits from something else?


Solution

  • You can do that in -init by creating an instance of the desired target class and resetting self. Be sure to send a -release message to the previous instance if you do that, though.