Overriding dealloc()


#1

I was reading the documentation on dealloc() and I had a simple question to which I couldn’t find a clear answer. When overriding dealloc(), the documentation states that you shouldn’t invoke the superclass’s implementation. But by overriding the implementation like below, does the delegate still get deallocated as it should?

-(void)dealloc { [locationManager setDelegate:nil]; }


#2

Yes, everything will still work as expected. ARC forbids calling dealloc explicitly. dealloc calls “get inserted” by the compiler at compile time. So, although you aren’t typing in [super dealloc]; when you override the dealloc method, it is still getting called, as it is being inserted by the compiler.