Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
Like this article? We recommend


In Cocoa/Objective-C there does not appear to be a hard and fast rule to determine whether a developer should subclass or use a delegate. With existing framework classes, the decision has been made for you. If the class has a delegate, check to see whether the delegate can be used for the functionality you are looking for. If not, you may have no choice but to subclass.

Categories are great for adding additional functionality to existing objects or even correcting the behavior of existing objects. However, with that power comes a much larger risk of causing unexpected changes in your application. This is especially true if another class is expecting the incorrect behavior that you correct!

Between Categories and Delegates, I rarely find myself extending any class in Cocoa/Objective-C other than NSManagedObject and NSObject. There rarely is a need. As with all things in programming the old adage of the "right tool for the job" applies. However with Cocoa, there are quite a few new tools to play with.

  • + Share This
  • 🔖 Save To Your Account