0
我不知道,如果泄漏發生在我的實現還是從蘋果的一側....核心數據,NSFetchResultsController泄漏
儀器指示我,我在這條線的漏水
如果([自fetchedResultsController] performFetch:&錯誤]!)
我通過閱讀fetchController到地圖....這樣添加註釋:
-(void)fillMapWithAnnotations{
NSError *error = nil;
if (![[self fetchedResultsController] performFetch:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
for(int a=0; a<[[[fetchedResultsController sections]objectAtIndex:0] numberOfObjects]; a++){
LookAround *look=(LookAround *)[fetchedResultsController objectAtIndexPath:[NSIndexPath indexPathForRow:a inSection:0]];
if(look){
AddAnnotation *newAnnotation=[[AddAnnotation alloc]initWithLookAround:look];
if(newAnnotation){
[self.mapView addAnnotation:newAnnotation];
[newAnnotation release];
newAnnotation=nil;
}
}
}
}
,我初始化我FetchController這樣的:
- (NSFetchedResultsController *)fetchedResultsController{
// Set up the fetched results controller if needed.
if (fetchedResultsController == nil) {
// Create the fetch request for the entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"LookAround" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
// Edit the section name key path and cache name if appropriate.
// nil for section name key path means "no sections".
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;
[aFetchedResultsController release];
[fetchRequest release];
[sortDescriptor release];
[sortDescriptors release];
}
return fetchedResultsController;
}
我儘快拿到泄漏,因爲我向後導航,在視圖控制器被釋放在我釋放我取控制器對象。
是泄漏的對象很多(與同類型的我猜的)
在此先感謝您的幫助....圍繞在我的SQLite數據庫的記錄數
我猜你的AddAnnotation類的泄漏是 – RunLoop 2010-06-26 05:40:23
yup ..我沒有發佈它的iVar ...非常感謝 – jAmi 2010-06-26 10:15:55
@JK - 你需要將你的評論移動到答案,jAmi需要檢查標記它如答覆。否則,這個問題將顯示爲永遠無法解答。 – TechZen 2010-06-26 16:49:32