【问题标题】:Core Data methods not in header file核心数据方法不在头文件中
【发布时间】:2011-04-06 10:04:23
【问题描述】:

为什么这些方法也不应该在头文件中?这是由 xcode btw 生成的。

界面

@class Environment, Location;

@interface Log : NSManagedObject {
@private
}
@property (nonatomic, retain) NSDate * date;
@property (nonatomic, retain) NSString * time;
@property (nonatomic, retain) NSNumber * distance;
@property (nonatomic, retain) NSString * comment;
@property (nonatomic, retain) NSSet* locations;
@property (nonatomic, retain) NSSet* environments;

@end

实施

@implementation Log
@dynamic date;
@dynamic time;
@dynamic distance;
@dynamic comment;
@dynamic locations;
@dynamic environments;

- (void)addLocationsObject:(Location *)value {    
    NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
    [self willChangeValueForKey:@"locations" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
    [[self primitiveValueForKey:@"locations"] addObject:value];
    [self didChangeValueForKey:@"locations" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
    [changedObjects release];
}

- (void)removeLocationsObject:(Location *)value {
    NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
    [self willChangeValueForKey:@"locations" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
    [[self primitiveValueForKey:@"locations"] removeObject:value];
    [self didChangeValueForKey:@"locations" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
    [changedObjects release];
}

- (void)addLocations:(NSSet *)value {    
    [self willChangeValueForKey:@"locations" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
    [[self primitiveValueForKey:@"locations"] unionSet:value];
    [self didChangeValueForKey:@"locations" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
}

- (void)removeLocations:(NSSet *)value {
    [self willChangeValueForKey:@"locations" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
    [[self primitiveValueForKey:@"locations"] minusSet:value];
    [self didChangeValueForKey:@"locations" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
}


- (void)addEnvironmentsObject:(Environment *)value {    
    NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
    [self willChangeValueForKey:@"environments" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
    [[self primitiveValueForKey:@"environments"] addObject:value];
    [self didChangeValueForKey:@"environments" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
    [changedObjects release];
}

- (void)removeEnvironmentsObject:(Environment *)value {
    NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
    [self willChangeValueForKey:@"environments" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
    [[self primitiveValueForKey:@"environments"] removeObject:value];
    [self didChangeValueForKey:@"environments" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
    [changedObjects release];
}

- (void)addEnvironments:(NSSet *)value {    
    [self willChangeValueForKey:@"environments" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
    [[self primitiveValueForKey:@"environments"] unionSet:value];
    [self didChangeValueForKey:@"environments" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
}

- (void)removeEnvironments:(NSSet *)value {
    [self willChangeValueForKey:@"environments" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
    [[self primitiveValueForKey:@"environments"] minusSet:value];
    [self didChangeValueForKey:@"environments" withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
}


@end

【问题讨论】:

    标签: iphone core-data


    【解决方案1】:
    【解决方案2】:

    它们由核心数据框架在运行时生成

    【讨论】:

      猜你喜欢
      • 2011-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多