我无法收到通知:
用于执行NSURLConnection异步填充的类
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:_receivedData, @"receivedData", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kWebServiceURLTemperaturaMaximaKMLNotitificationName object:self userInfo:userInfo];
}
另一个观察通知的班级:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceivedCompleteData:) name:kWebServiceURLTemperaturaMaximaKMLNotitificationName object:self];
有什么想法吗?
答案 0 :(得分:2)
错误在这里:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceivedCompleteData:) name:kWebServiceURLTemperaturaMaximaKMLNotitificationName object:self];
这意味着通知中心会将名为name:kWebServiceURLTemperaturaMaximaKMLNotitificationName
的通知发送到self
,该通知也由self
生成。您应该将object:self
替换为object:nil
(以接收任何名为name:kWebServiceURLTemperaturaMaximaKMLNotitificationName
的通知)或实际发送通知的对象。