0

What is the @private for in the file generated by Core Data below? I know what @private means in Objective-C, but there are not instance variables listed after it, so can't I just take it out?

//
//  Event.h
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>


@interface Event : NSManagedObject {
@private
}
@property (nonatomic, retain) NSDate * timestamp;

@end


//
//  Event.m
//  

#import "Event.h"


@implementation Event
@dynamic id;

@end
Community
  • 1
  • 1
ma11hew28
  • 121,420
  • 116
  • 450
  • 651

3 Answers3

4

You can safely take it out, it won't change the semantics of your class. If you're not statisfied with what XCode generates for you (though it's a reasonable default), I'd suggest you take a look at https://github.com/rentzsch/mogenerator.

Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
  • Thanks. I'll check out mogenerator. I passed on it once before, but I think it's time... not just for making model changes easier, but also being able to track the changes with git. The files in the `.xcdatamodel` bundle are binary, so I can't see the diffs. – ma11hew28 Apr 16 '11 at 06:04
1

You can, but it doesn't hurt. If you generate the model again it will just put it back.

Black Frog
  • 11,595
  • 1
  • 35
  • 66
1

Xcode now defaults to generating classes with @private for instance variables, which you are supposed to declare in case you need them. You can safely remove that @private since, as you’ve already noticed, there are no instance variables. In fact, that class declaration is equivalent to

@interface Event : NSManagedObject
@property (nonatomic, retain) NSDate * timestamp;   
@end