这是我获取对象数组的代码:
-(BOOL)isAvailable:(NSString*)aName
{
BOOL isAvailable = NO;
NSEntityDescription *ed = [Queue entityInManagedObjectContext:moc];
NSFetchRequest *fr = [[NSFetchRequest alloc] init];
[fr setEntity:ed];
NSPredicate *pr = [NSPredicate predicateWithFormat:@"textName == %@", aName];
[fr setPredicate:pr];
NSArray *arr = [moc executeFetchRequest:fr error:nil];
if ([arr count] > 0) {
isAvailable = YES;
}
return isAvailable;
}
内存泄漏在:
NSArray *arr = [moc executeFetchRequest:fr error:nil];
如果评论此行,则没有任何泄漏。我使用 ARC 项目。