Convert between NSData and NSDictionary
We can simplu use NSKeyedArchiver to serialize NSDictionary. To convert NSDictionary to NSData:
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:yourDictionary forKey:@"Some Key Value"];
[archiver finishEncoding];
[archiver release];
/** data is ready now, and can use it **/
[data release];
To deserialize a NSData:
NSData *data = [[NSMutableData alloc] initWithContentsOfFile:[self dataFilePath]];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
NSDictionary *myDictionary = [[unarchiver decodeObjectForKey:@"Some Key Value"] retain];
[unarchiver finishDecoding];
[unarchiver release];
[data release];

Recent comments
32 weeks 3 days ago
37 weeks 5 days ago
41 weeks 23 hours ago
42 weeks 21 hours ago
50 weeks 6 days ago
50 weeks 6 days ago
51 weeks 7 hours ago
51 weeks 1 day ago
1 year 5 days ago
1 year 6 days ago