我似乎無法找出泄漏工具報告的問題的原因。有問題的代碼在這裏標有問題行。有任何想法嗎?有沒有辦法找出泄漏究竟是什麼物體?問題內核中的內存泄漏數據代碼
NSArray *getAllCoreData(NSString *entityName, NSString *orderedBy, BOOL ascending, BOOL shallow)
{
// Get the managed object context
NSManagedObjectContext *moc = [[AppController sharedAppController] managedObjectContext];
// Create a fetch request that fetches from 'entityName'
NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:moc];
[fetch setEntity:entity];
// Try to do the fetch
NSError *error;
NSArray *result = [moc executeFetchRequest:fetch error:&error]; <----- Problem line
[fetch release];
// Did the fetch fail?
if (!result)
{
// Display an alert view
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Fetch Failed"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView autorelease];
[alertView show];
return nil;
}
// Return the array of instances of NSManagedObject
return result;
}
任何幫助,將不勝感激, 傑森
你好賈森,我也面臨類似的問題,所以你可以請張貼解決這個問題? – ujjawal