Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 核心数据,NSFetchResultsController泄漏_Iphone_Objective C_Xcode_Core Data_Memory Leaks - Fatal编程技术网

Iphone 核心数据,NSFetchResultsController泄漏

Iphone 核心数据,NSFetchResultsController泄漏,iphone,objective-c,xcode,core-data,memory-leaks,Iphone,Objective C,Xcode,Core Data,Memory Leaks,我不确定漏洞是在我的实现中还是来自苹果方面 仪器显示我的管线有泄漏: if(![[self-fetchedResultsController] 性能蚀刻:&错误]) 我正在通过将fetchController读取到地图来添加注释。。。。像这样: -(void)fillMapWithAnnotations{ NSError *error = nil; if (![[self fetchedResultsController] performFetch:&error]) {

我不确定漏洞是在我的实现中还是来自苹果方面

仪器显示我的管线有泄漏:

if(![[self-fetchedResultsController] 性能蚀刻:&错误])

我正在通过将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;
            }
        }
    }



}
我一导航回来就发现了漏洞,ViewController被释放,我在其中释放了fetch controller对象

泄漏的对象在我的sqlite DB中的记录数周围有很多(我猜是同一类型的)


提前感谢您的帮助……

正如我前面提到的,泄漏可能在您的AddAnnotation类中。

我猜泄漏在您的AddAnnotation类中是的。。在那里我没有释放它的iVar。。。多谢各位much@JK-您需要将您的评论移至答案,jAmi需要选中标记为已回答。否则,这个问题将永远无法回答。
- (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;
}