views:

97

answers:

2

I am using core data and am generating classes from my data model.

I implement custom methods in these classes, however when i regenerate i generate over the top so i end up copying and pasting a bit. What i would like to do is split my implementation files ('.m') so i can have one header file with multiple '.m' files. then i can keep my custom methods in one and not have to worry about erasing them when i regenerate. I use this technique in .NET a lot with its partial keyword. Is there anything similar in objective-C

+3  A: 

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

If your CoreData class is named Person your implementation could go into the category Implementation but note that you have to 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
Till Theis
+2  A: 

You may also want to look at mogenerator, which takes a different approach to generating classes for entities.

Peter Hosey
Exactly what i needed, although it uses derived classes, but makes generation a breeze. thanks.
Aran Mulholland