<p>When I've registered an object <strong>foo</strong> to receive KVO notifications from another object <strong>bar</strong> (using addObserver:...), if I then deallocate <strong>foo</strong> do I need to send a <code>removeObserver:forKeyPath:</code> message to <strong>bar</strong> in -dealloc?</p>

You need to use
```
-removeObserver:forKeyPath:
```
to remove the observer before
```
-[NSObject dealloc]
```
runs, so yes, doing it in the
```
-dealloc
```
method of your class would work.
Better than that though would be to have a deterministic point where whatever owns the object that's doing the observing could tell it it's done and will (eventually) be deallocated.  That way, you can stop observing immediately when the thing doing the observing is no longer needed, regardless of when it's actually deallocated.
This is important to keep in mind because the lifetime of objects in Cocoa isn't as deterministic as some people seem to think it is.  The various Mac OS X frameworks themselves
will
send your objects
```
-retain
```
and
```
-autorelease
```
, extending their lifetime beyond what you might otherwise think it would be.
Furthermore, when you make the transition to Objective-C garbage collection, you'll find that
```
-finalize
```
will run at very different times — and in very different contexts — than
```
-dealloc
```
did.  For one thing, finalization takes place on a different thread, so you really
can't
safely send
```
-removeObserver:forKeyPath:
```
to another object in a
```
-finalize
```
method.
Stick to memory (and other scarce resource) management in
```
-dealloc
```
and
```
-finalize
```
, and use a separate
```
-invalidate
```
method to have an owner tell an object you're done with it at a deterministic point; do things like removing KVO observations there.  The intent of your code will be clearer and you will have fewer subtle bugs to take care of.