Iphone 调用ViewController返回nil

Iphone 调用ViewController返回nil,iphone,core-data,Iphone,Core Data,在这个阶段,我花了好几天的时间试图解决这个问题,我希望你能帮助我 我有两个ViewController,它们使用核心数据从同一数据库查询两个不同的表。第一个ViewController随应用程序一起打开,显示良好。第二个从第一个ViewController中调用,使用相当标准的获取设置: - (NSFetchedResultsController *)fetchedClients { // Set up the fetched results controller if needed.

在这个阶段,我花了好几天的时间试图解决这个问题,我希望你能帮助我

我有两个ViewController,它们使用核心数据从同一数据库查询两个不同的表。第一个ViewController随应用程序一起打开,显示良好。第二个从第一个ViewController中调用,使用相当标准的获取设置:

- (NSFetchedResultsController *)fetchedClients {
    // Set up the fetched results controller if needed.
    if (fetchedClients == nil) {
        // Create the fetch request for the entity.
        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
        // Edit the entity name as appropriate.
        NSEntityDescription *entity = [NSEntityDescription entityForName:@"Clients" 
              inManagedObjectContext:managedObjectContext];
        [fetchRequest setEntity:entity];




        // Edit the sort key as appropriate.
        NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"clientsName" 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.fetchedClients = aFetchedResultsController;

        [aFetchedResultsController release];
        [fetchRequest release];
        [sortDescriptor release];
        [sortDescriptors release];
    }

 return fetchedClients;
}    
当我调用[self.fetchedClients节]时,我得到一个nil(0x0)返回值


我已经使用外部应用程序检查了数据库,以确保“Clients”表中存在数据。

您是根据3.0编译的吗?是3.0中的一个bug,在3.1中修复了该bug,可能导致此问题

更新
您正在对返回的NSFetchedResultsController调用-performFetch:?我在你发布的代码中没有看到

您是针对3.0进行编译的吗?是3.0中的一个bug,在3.1中修复了该bug,可能导致此问题

更新
您正在对返回的NSFetchedResultsController调用-performFetch:?我在你发布的代码中没有看到

谢谢。对最新和最伟大(ish)3.1.3谢谢。对最新和最大(ish)3.1.3