I was debugging the application that I am creating, but with the help of tools I found a memory leak that I cannot understand.
If I try to change the code following the βToolsβ sentence, my application will crash due to
sent to an exempted instance
Can someone help me?
- (void) objectAtIndex:(int)index {
SpecialObject *specialObj = [SpecialObject sharedInstance];
id model = [self.datasource objectAtIndex:index];
if ([model isKindOfClass:[ClassA class]]) {
ClassA *objA = (ClassA *)model;
specialObj.title = objA.title;
} else if ([model isKindOfClass:[ClassB class]]) {
ClassB *objB = (ClassB *)model;
specialObj.title = objB.title;
}
}
self.datasourceis NSMutableArray, and specialObj.titleisNSString
They are defined as @property(nonatomic, retain).
My problem is that Tools tell me that these 2
ClassA *objA = (ClassA *)model;
ClassB *objB = (ClassB *)model;
are leaks, but if I release objAand objB, I crash the application.
Thanks for any help!
source
share