i want to save a mutable dictionary to file. the dictionary has several mutable arrays that contain custom object that I implemented. I've implemented the NSCoder protocol in my class but for some reason the property values in those objects get set to nil when the dictionary is read from the file. this is what i've tried for reading
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString * filePath = [NSString stringWithFormat:@"%@/list.txt",documentsDir];
NSData * data = [[NSData alloc] initWithContentsOfFile:filePath];
NSKeyedUnarchiver * unarchiver = [[NSKeyedUnarchiver alloc]initForReadingWithData:data];
NSMutableDictionary * dictionary = [unarchiver decodeObjectForKey:@"mylist"];
[unarchiver finishDecoding];
and this is what i've tried for writing to the file
NSMutableData * data = [[NSMutableData alloc]init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]initForWritingWithMutableData:data];
[archiver encodeObject:myDictionary forKey:@"mylist"];
[archiver finishEncoding];
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString * filePath = [NSString stringWithFormat:@"%@/list.txt",documentsDir];
[data writeToFile:filePath atomically:YES];