Release method for Objective-C

I have a class that keeps a count of all instances. It increases the count when an instance is allocated and needs to decrease it when the object is deallocated. Knowing when the object is allocated is easy, this can be done in the constructor. How do I know when the object is deallocated?

With the JVM I can override finalize. But on iOS, it is never called. Is there a common way to do this or an Objective-C way?

For anyone that needs it, how I achieved this was by keeping the finalize method for the JVM. Then from Objective-C, I created a common category for the class which overrides the dealloc message, calls finalize and dealloc.

- (void)dealloc
    [self finalize];
    [super dealloc];

The compiler complains about overriding dealloc from a category, but this is the only way I’ve found to achieve it.