0

在我的 prepareForSegue 方法中,我正在这样做:

LoggedInViewController *view = segue.destinationViewController;

NSLog(@"Preparing for view logged in for user %@ with %d zombies with %@",
          self.context.userName, self.context.zombies.count, view.view);

[view initWithContext:self.context];

在我的initWithContext方法中:

- (void)initWithContext:(TestSRConnectionContext *)__context{
    _context = __context;
    NSLog(@"Ok init for user %@ with %d zombies", __context.userName, _context.zombies.count);

}

在日志中一切都很好。

我正在加载的视图是 UITableViewController 但没有加载任何项目。我以前有这个表工作过,所以表的逻辑没问题。

所以 - 我遇到的问题是视图出现时 _context.zombies 设置为 null;在 viewDidAppear 方法中,我检查了 _context.zombies,它为空!

4

1 回答 1

1

我写错了问题 - context 不是 null 而是 context.zombies 是。

我将属性声明上的弱属性更改为强,现在它可以工作了。

于 2012-07-12T07:28:53.783 回答