当我从CoreData实体生成我的类时,我得到生成的方法
@interface Site (CoreDataGeneratedAccessors)
- (void)addSearchesObject:(Search *)value;
- (void)removeSearchesObject:(Search *)value;
- (void)addSearches:(NSSet *)value;
- (void)removeSearches:(NSSet *)value;
@end
所以当我调用removeSearchesObject时,我的问题非常简单:myObject我是否也必须删除它?
[site removeSearchesObject:[[fetchedResultsController fetchedObjects] objectAtIndex:indexPath.section]];
[context deleteObject:[[fetchedResultsController fetchedObjects] objectAtIndex:indexPath.section]];
这是生成的代码(来自 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];
}