小编Fsd*_*sdn的帖子

CoreDataGeneratedAccessors - removeObject会删除对象吗?

当我从CoreData实体生成我的类时,我得到生成的方法

@interface Site (CoreDataGeneratedAccessors)
- (void)addSearchesObject:(Search *)value;
- (void)removeSearchesObject:(Search *)value;
- (void)addSearches:(NSSet *)value;
- (void)removeSearches:(NSSet *)value;

@end
Run Code Online (Sandbox Code Playgroud)

所以当我调用removeSearchesObject时,我的问题非常简单:myObject我是否也必须删除它?

[site removeSearchesObject:[[fetchedResultsController fetchedObjects] objectAtIndex:indexPath.section]];
        [context deleteObject:[[fetchedResultsController fetchedObjects] objectAtIndex:indexPath.section]];
Run Code Online (Sandbox Code Playgroud)

这是生成的代码(来自doc)

- (void)removeEmployeesObject:(Employee *)value

{

    NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];



    [self willChangeValueForKey:@"employees"

          withSetMutation:NSKeyValueMinusSetMutation

          usingObjects:changedObjects];

    [[self primitiveEmployees] removeObject:value];

    [self didChangeValueForKey:@"employees"

          withSetMutation:NSKeyValueMinusSetMutation

          usingObjects:changedObjects];



    [changedObjects release];

}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch core-data objective-c

11
推荐指数
1
解决办法
3335
查看次数

标签 统计

cocoa-touch ×1

core-data ×1

iphone ×1

objective-c ×1