NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"raw"];
NSMutableDictionary *data = [[[NSMutableDictionary alloc]init]autorelease];
[data setObject:[NSString stringWithFormat:@"aaa"] forKey:@"aaaKey"];
[data setObject:[NSString stringWithFormat:@"bbb"] forKey:@"bbbKey"];
[NSKeyedArchiver archiveRootObject:data toFile:path];
NSMutableDictionary *data = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
NSLog(@"aaaKey : %@\n",[data objectForKey:@"aaaKey"]);
NSLog(@"bbbKey : %@\n",[data objectForKey:@"bbbKey"]);
沒有留言:
張貼留言