With the following code the analyzer marks the setMyDict selector call as a potential leak and in dealloc it states "Incorrect decrement of the reference count is not owned at this point by the caller"
- (id)init {
if (self = [super init]) {
[self setMyDict:[[NSMutableDictionary alloc] init]];
}
return self;
}
- (void)dealloc {
[[self myDict] release];
[super dealloc];
}
@synthesize myDict = _myDict;
I do not understand this. I thought, that with the alloc init the object increases the retain count by one and the pointer is stored in _myDict through the synthesized property. If I use this code instead
- (id)init {
if (self = [super init]) {
_myDict = [[NSMutableDictionary alloc] init];
}
return self;
}
- (void)dealloc {
[_myDict release];
[super dealloc];
}
Analyzer does not complain. What am I missing?