Pregunta

If I have several different groups of methods that I would like to use in multiple classes, which are all subclasses of UIViewController, would it be better style to include all of these methods into a single category, like UIViewController+allGeneralMethods.h

or have multiple categories like UIViewController+Animations.h , UIViewController+GestureRecognizers , UIViewController+DateFormatters , etc.

¿Fue útil?

Solución

I assume that your goal is to keep your code easy to investigate, use and modify.

Put all groups in one category if:

  1. Most of your classes will use methods from all groups.
  2. Each group includes only 1-2 methods.
  3. Your development team is small and you do not expect that a lot of people will read your code (fragmented code easier to understand).

Put your code in several categories in other cases.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top