运行项目时,我在输出窗口中得到以下信息:
An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: connection.messageQueue
Observed object: <Client: 0x10011ddb0>
...
你明白了。问题是,我不知道为什么会这样。但是,似乎一切正常。这是导致问题的代码:
-(id) initWithIdentifier:(NSString*)ident andClient:(Client*)chatClient {
if(![super initWithNibName:@"ChatView" bundle:nil]) {
return nil;
}
[self setTitle: ident];
client = chatClient;
[self setIdentifier:ident];
inContext = false;
[client addObserver:self forKeyPath:@"connection.messageQueue" options:NSKeyValueObservingOptionNew context:NULL];
return self;
}
-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
NSAttributedString* rar = [[NSAttributedString alloc] initWithString:@"test"];
[[textView textStorage] appendAttributedString:rar];
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
我想我会展示与此相关的所有代码。该类只有几个方法,所以这就是您需要查看的全部内容。我什至没有使用更改,我只是在 KVO 事件被触发时进行“测试”。
由于消息一直在进来,堆栈跟踪变得非常快。然而,似乎一切正常。
有什么线索吗?