Override dealloc for worldView and locationTitleField too?


After working through chapter 4 I understood why the dealloc method is overridden (even though it is not strictly necessary in this application) so the locationManager object has it’s delegate property set to point to nil, rather than at the WhereamiViewController object.

However, in Chapter 5 I was surprised to see the other two delegate introduced in this chapter (worldView, and locationTitleField) not mentioned. I was expecting to see these delegate references set to nil in the WhereamiViewController’s dealloc method too as follows:

- (void)dealloc
    [locationManager setDelegate:nil];
    [worldView setDelegate:nil];
    [locationTitleField setDelegate:nil];

Is this correct thinking? I’m just trying to cement my understanding here. So, if we send the setDelegete: message for locationManager, should we not also do the same for worldView and locationTitleField too?

If not, then what is the reason for doing it for locationManager and not the other two? Any insights would be welcomed.

P.S. Really enjoying the book and getting deeper into iOS development! :slight_smile:


Yup, this is being really safe, but sometimes that is good.