+ (NSArray *) fetchAllContactsInContext:(NSManagedObjectContext *)a_context
{
NSFetchRequest *_request = [[NSFetchRequest alloc] init];
[_request setEntity:[NSEntityDescription entityForName:@"Contact" inManagedObjectContext:a_context]];
NSSortDescriptor *_sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
NSArray *_sortDescriptors = [[NSArray alloc] initWithObjects:_sortDescriptor, nil];
[_request setSortDescriptors:_sortDescriptors];
NSError *_fetchError=nil;
NSArray *_results = [[NSArray alloc] initWithArray:[a_context executeFetchRequest:_request error:&_fetchError]];
[_sortDescriptor release];
[_sortDescriptors release];
[_request release];
if (_fetchError){
NSLog(@"Contact - Error fetching contacts %@", [_fetchError localizedDescription]);
}
[_fetchError release];
return [_results autorelease];
}
我想问一下,这个函数是否泄漏内存?实际上 Instruments 是说这个函数正在泄漏大量内存。
你能帮我解决内存问题吗?