0

我已经UITableViewController didSelectRowAtIndexPath通过以下方式覆盖了我的方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    PhotoListViewController *photosViewController = [[PhotoListViewController alloc] initWithStyle:UITableViewStylePlain];

    NSLog(@"Let's see what we got %d", [[fetchedResultsController fetchedObjects] count]);

    Person *person = [fetchedResultsController objectAtIndexPath:indexPath];
    photosViewController.person = person;
    photosViewController.title = [person.name stringByAppendingString:@"'s Photos"];

    [self.navigationController pushViewController:photosViewController animated:YES];

    [photosViewController release];
}

每当我尝试访问时,fetchedResultsController我都会崩溃,我在这里设置它:

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"person = %@", person];
        fetchedResultsController = [[FlickrFetcher sharedInstance] fetchedResultsControllerForEntity:@"Photo" withPredicate:predicate];
    }
    return self;
}

而且我只在我的dealloc方法中发布它

4

1 回答 1

5

在调用 didSelectRowAtIndexPath 方法之前,您的自动释放池似乎已经耗尽。您是否尝试像这样保留 fetchedResultsController:

fetchedResultsController = [[[FlickrFetcher sharedInstance] fetchedResultsControllerForEntity:@"Photo" withPredicate:predicate] retain];
于 2011-07-08T15:33:59.043 回答