Having redone the project in Xcode 3.2.6 with the same results (i.e. the leak of DataItem not detected), I did a little research. Several sources (stackoverflow has several responses to related issues) claim that Leaks only detects a leak if a reference to the object no longer exists. To test this I did the following
Code:
-(IBAction)addDataToDictionary:(id)sender
{
NSString *str = nil;
DataItem *item = [[DataItem alloc] init];
item.age = self.ageTextField.text;
item.name = self.nameTextField.text;
[self.dataArray addObject:item];
str = [[NSString alloc] initWithFormat:@"Current count = %d",[self.dataArray count]];
totalCountLabel.text = str;
if ([self.dataArray count]%10 == 0) {
[self printLog];
}
}
-(void)printLog
{
NSLog(@"The count has gone up by 10");
NSLog(@"removing all objects");
[self.dataArray removeAllObjects];
}
After the objects are removed from the array, the leaks do show up. No references, but a retain count greater than 0. This matches the behavior that the stackoverflow respondent said would occur
http://stackoverflow.com/questions/1...ure-they-exist
Bob