I have an archive which is stored in "Presidents.plist" file. It exist and I can locate it using pathForResource
method. And also I do get the data using initWithContentsOfFile
method of NSData
to retrieve the data. The problem now is in this lines of code.
NSString *path = [[NSBundle mainBundle] pathForResource:@"Presidents"
ofType:@"plist"];
NSData *data;
NSKeyedUnarchiver *unarchiver;
data = [[NSData alloc] initWithContentsOfFile:path];
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
id presidents = [unarchiver decodeObjectForKey:@"Presidents"];
For some reason it is returning a null class instead of my expected NSArray class. Can anyone tell me the reason this is happening and how can I solve this dilemma?
I'm getting the class like this...
NSLog(@"presidents class = %@", NSStringFromClass([presidents class]));