there are 2 object: A and B
call [A addObserver:B for keyPath:...];
if i release object A in somewhere. have to Call [A removeObserver:开发者_如何转开发B...] first?
if i release object B in somewhere. have to Call [A removeObserver:B...] first?
You only need to do the second one to avoid A
sending a message to a deallocated object.
As a matter of good practive, you should remove your observer when it is not needed anymore but not doing so will not cause any problems as neither objects are retained by the message so if you release A it will stop observing B and if you release B the observed value will never change so your KVO observing method will never be called.
精彩评论