Reputation: 15021
I have two classes that are already subclasses of a different parent (due to an external library I cannot change this). However I want to share some common code between them, say for example, code that handles an action after a popup dialog etc. How do I do this?
Upvotes: 0
Views: 96
Reputation: 29051
Refactor the shared code into its own class, and include an instance of that class as a field/property within your other two classes.
Upvotes: 4
Reputation: 388
You could write a category on a common ancestor class. Then both classes could import that Category and call the common code.
Upvotes: 1
Reputation: 59299
You can re-factor the appropriate code into a utilities class, and then have the two classes call it. As for the iPhoneSDK, you can probably have the utility method be the delegate method itself.
Upvotes: 1