can we override alloc and dealloc in objective C?

User97693321 picture User97693321 · Sep 29, 2011 · Viewed 7.4k times · Source

I know that this is rarely required to override the alloc or dealloc methods,but if required is it possible in iPhone programming?

Answer

Adam Wright picture Adam Wright · Sep 29, 2011

You can and indeed, you should (if using manual memory management) override dealloc to release any resources you hold (not forgetting to call [super dealloc] when finished). Overriding alloc is possible but, as you say, rarely needed.