I read a tip here in a SO best practices posting:
"If you're passing yourself as a delegate to another object, reset that object's delegate before you dealloc." EXAMPLE:
- (void)dealloc {
if (self.someObject.delegate == self) {
self.someObject.delegate = NULL;
}
self.someObject = NULL;
[super dealloc];
}
Sounds reasonable, but I'm not sure in what cases I need to do that. For example, I have a view controller like the one below:
- (void) viewDidLoad {
myTextField.returnKeyType = UIReturnKeyDone;
myTextField.delegate = self;
}
Would I (Should I) set the delegate to NULL in that case, for example:
- (void) dealloc {
if (self.myTextField.delegate == self) {
self.myTextField.delegate = NULL;
}
[myTextField release];
[super dealloc];
}