Objective-C partial implementation of classes in separate files

I use basic data and I generate classes from my data model.

I implement custom methods in these classes, however, when I regenerate, I generate from above to end up copying and pasting a bit. I would like to split my implementation files (".m"), so I can have one header file with several ".m" files. then I can save my own methods in one, and there is no need to worry about deleting them when I regenerate. I often use this method in .NET with its partial keyword. Is there something similar in objective-C

+6
objective-c iphone class-design cocoa
source share
2 answers

You can also see a mogenerator that takes a different approach to generating classes for objects.

+2
source share

In Objective-C, you have categories (and extensions) .

If your CoreData class is named Person , your implementation may go into the Implementation category, but note that you must declare all your ivars in the main interface of your class.

 // Person+Implementation.h #import "Person.h" @interface Person (Implementation) - (void)myMethod; @end // Person+Implementation.m #import "Person+Implementation.h" @implementation Person (Implementation) - (void)myMethod { NSLog(@"hi there"); } @end 
+16
source share

All Articles