Monday, February 20, 2012

Extending NSData and (Not) Overriding Dealloc

Tom Harrington:

You can’t override -dealloc in a category. But thanks to associated objects, you don’t have to. If have some object A, and you associate a secondary object B with it, then when A gets deallocated, B will too. If you have something you really need to happen when A gets deallocated, you can call that code from B’s dealloc method. Bingo, deallocation code for A that runs in a separate class.

Comments RSS · Twitter

Leave a Comment