Search code examples
iosobjective-cobjective-c-category

categories vs utility classes in iOS


Why are utility classes considered bad practice in iOS ? And categories used as a replacement instead of helper classes/utility classes. Is there any particular benefit that we get out of categories that we don't get from utility classes ?


Solution

  • Categories have a specific purpose. They extend functionality of a class in code that's external to the class for some reason (you don't have source for the original, you want different visibility for the category, ...).

    When you say "helper" class, that sounds like delegates rather than categories...or just simple composition.

    Actual utility classes -- ones that have no instances or state -- do exist where needed.