I have a class (MyClass) with a lot of methods. Consequently, the .m file has become quite difficult to read. I’m relatively new to Objective-C (having come from REALbasic) and I was wondering if it’s possible to put some of the methods in MyClass into different files and then include them in the class. How would I go about this in Xcode?
I have a class ( MyClass ) with a lot of methods. Consequently, the
Share
Yes it is possible and fortunately this can be done easily in Objective-C with Categories.
Say you have your base class
MyClass.And the according implementation file (not relevant here).
Then you can create a category by defining a new interface in a new header file:
and the implementation file:
Common convention to name these files is ClassToAddMethodsTo+CatgoryName, i.e.:
Group related functionality into categories and give it a meaningful name.