Hi
Can anyone tell me what I am doing wrong in the following few lines?
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *documentsDirectory = [paths objectAtIndex:0]; documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"Immobilien.plist"]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:documentsDirectory]; if (!fileExists) { //NSLog(@"file does not exist yet"); NSString *content = @""; NSData *fileContents = [content dataUsingEncoding:NSUTF8StringEncoding]; [[NSFileManager defaultManager] createFileAtPath:documentsDirectory contents:fileContents attributes:nil]; } NSMutableArray *bookDicts = [NSMutableArray arrayWithContentsOfFile:documentsDirectory]; [_displayedObjects release]; _displayedObjects = [[NSMutableArray alloc] initWithCapacity:[bookDicts count]];
for (NSDictionary *currDict in bookDicts)
{
Book *book = [[Book alloc] initWithDictionary:currDict];
if ([book.wohnungen count] != 0) {
[_displayedObjects addObject:book];
}
[book release];
}
Xcode's instruments is telling me that there is a memory leak in the following line:
NSMutableArray *bookDicts = [NSMutableArray arrayWithContentsOfFile:documentsDirectory];
I cannot figure out what I am doing wrong.
Thank you very much for helping me
regards
Phil