2
我想从核心数据中删除所有的NSEntityDescription对象并释放内存。该reset
功能没有任何差别的内存从核心数据列表中删除NSEntityDescription对象
下面是我的代码
-(void)generatePersons: (NSManagedObjectContext *)privatecontext{
self.persons = [[NSMutableArray alloc]init];
[privatecontext performBlockAndWait:^{
for(int i = 1; i< self.dataRows.count; i++){
NSArray *HeaderRow = [self.dataRows objectAtIndex:1];
NSArray *dataRow = [self.dataRows objectAtIndex:i];
if (dataRow.count <= HeaderRow.count){
int index = 0;
Person *person = (Person *)[NSEntityDescription
insertNewObjectForEntityForName:@"Person"
inManagedObjectContext:privatecontext];
[self.persons addObject:person];
}
}
[privatecontext reset];
}];
}
这个代码[privatecontext reset];
理论上设定的背景下其基本状态,在我的理解它会释放内存,以及但它不会并保持相同的内存数量
所有这些实例仍然由您的数组保留。 –
@TomHarrington即使我们评论此行''self.persons addObject:person];'即使在退出for循环范围和等待块范围 –