didSelectRowAtIndexPath 中的 EXC_BAD_ACCESS
我已经用以下方式覆盖了我的 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
方法中释放它
I have overwritten my UITableViewController
didSelectRowAtIndexPath
method the following way:
- (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];
}
Whenever I try to access the fetchedResultsController
I get the crash, I set it here:
- (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;
}
And I only release it in my dealloc
method
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在调用 didSelectRowAtIndexPath 方法之前,您的自动释放池似乎已耗尽。您是否尝试像这样保留 fetchedResultsController :
Seems like your autorelease pool is getting drained before your didSelectRowAtIndexPath method is called. Did you try retaining the fetchedResultsController like so: