2010-06-25 3 views
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; 
}  

я получаю утечку, как только я вернуться обратно, то ViewController будет освобождён, в котором я освобождаю мой выборки объект контроллера.

Объекты, которые просачиваются многочисленны (и того же типа, я думаю) вокруг числа записей в моей БД SQLite

Заранее спасибо за вашу помощь ....

+0

Я угадываю, что утечка находится в вашем классе AddAnnotation – RunLoop

+0

yup .. там я не выпускал его iVar ... Спасибо большое – jAmi

+0

@JK - вам нужно переместить свой комментарий к ответу, а jAmi нужно отметить его как было сказано. В противном случае этот вопрос будет показываться без ответа. – TechZen

ответ

1

Как я уже отмечал выше , утечка, вероятно, находится в вашем классе AddAnnotation.

Смежные вопросы