贴上资源。很简单
https://gist.github.com/rudyjahchan/2191796
http://stackoverflow.com/questions/5960049/callback-method-before-deallocating-any-object
http://justsee.iteye.com/blog/2019539
http://stackoverflow.com/questions/16811461/method-swizzling-for-alloc