I've read that you should set delegate to nil in dealloc
. I noticed it is doing it in init
, is this ok or should you do the same in the dealloc
?
"This is subtle one but handy one. If you're passing yourself as a delegate to another object, reset that object's delegate before you dealloc."
file.h
@interface TestService : NSObject
{
NSObject <TestServiceDelegate> *m_delegate;
}
@property (nonatomic, assign) NSObject <TestServiceDelegate> *delegate;
file.m
@synthesize delegate=m_delegate;
- (id)init
{
if (self = [super init])
{
m_delegate = nil;
}
return self;
}
- (void)dealloc
{
[super dealloc];
}