[sessionController.currentSession addObserver:self
forKeyPath:@"sessionState"
options:(NSKeyValueChangeSetting)
context:NULL];
这似乎不起作用。
此代码所在的类知道sessionController并且可以访问currentSession。 currentSession的sessionState变量是我想要观察的。是否 verboten 以我在这里完成的方式设置要观察的对象?
如果是这样,这样做的方法是什么?没有给观察对象一个currentSession变量。
答案 0 :(得分:0)
调用方法时,sessionController.currentSession是否包含有效值?
这是一个常见的陷阱,将消息发送到null将无声地失败。