here I have some code where the Leaks-Instrument detects leaks. The commented Numbers behind some lines taken out from the Leaks-Instrument.
I don't know what I have to do here. I have made many tries, have released and autoreleased, but no solution.
Can somebody show me where the problem is?
- (void) handleDataModel {
int theTag = [[themeDict valueForKey:KEY_TAG] intValue];
NSString *theFilePath = [self dataFilePathFromParentTag:theTag]; //1.02kb
NSString *strPath = [[[NSString alloc] initWithString:theFilePath] autorelease]; //32bytes
NSMutableData *userData = [[NSMutableData alloc] initWithContentsOfFile:strPath]; //32bytes
if (userData) {
_dataModel = [self newUnarchiveData: userData]; //544bytes
} else {
_dataModel = [[[ThemeDataModel alloc] initWithDictionary:themeDict] autorelease];
}
_dataModel.Modules = [self sortArray:_dataModel.Modules]; //64bytes
[self writeDataToFile:_dataModel]; //2,59kb
[userData release];
[strPath release];
}
- (NSString *)dataFilePathFromParentTag:(int)themeTag {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //1.41kb
NSString *documentsDirectory = [[paths objectAtIndex:0] retain];
NSString *fileName = [NSString stringWithFormat:@"%iTheme", themeTag]; //96bytes
NSString *theFile = [documentsDirectory stringByAppendingPathComponent:fileName]; //544bytes
[documentsDirectory release];
return theFile;
}
- (id) newUnarchiveData: (NSMutableData *) userData {
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:userData]; //352bytes
id model = [unarchiver decodeObjectForKey:KEY_DATA]; //192bytes
[unarchiver finishDecoding];
[unarchiver release];
return model;
}
- (void)writeDataToFile:(id)model {
NSMutableData *data = [[NSMutableData alloc] init]; //32bytes
[self archiveData:data model:model]; //1,30bytes
[data writeToFile:[self dataFilePathFromParentTag:[[model valueForKey:KEY_TAG] intValue]] atomically:YES]; //1,27bytes
[data release];
}
thank you xnz