Search code examples
iphoneobjective-ccocoakey-value-observing

about release object when using kvo in cocoa framework


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?


Solution

  • You only need to do the second one to avoid A sending a message to a deallocated object.