What is the @private
for in the file generated by Core Data below? I know what @开发者_JAVA技巧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
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.
You can, but it doesn't hurt. If you generate the model again it will just put it back.
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
精彩评论