Is there simple way to parse the binary plist file into the NSDictionary representation? I am searching something like that:
NSString* s开发者_开发知识库trings = [NSString stringWithContentsOfURL: ... encoding: NSUnicodeStringEncoding error: ...];
NSMutableDictionary* pairs = (NSMutableDictionary*)[strings propertyListFromStringsFileFormat];
Using this code caused the exception while parsing the binary plist file.
Are you looking for [NSDictionary dictionaryWithContentsOfFile:]
?
Considering a file called DataStorageFile.plist
, you can use:
NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"DataStorageFile" ofType:@"plist"];
self.data = [NSDictionary dictionaryWithContentsOfFile:dataPath];
If you want an array:
self.data = [NSArray arrayWithContentsOfFile:dataPath];
精彩评论