Search code examples
objective-ciosoverridingdeallocalloc

can we override alloc and dealloc in objective C?


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


Solution

  • 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.