开发者

Read binary plist into NSDictionary

开发者 https://www.devze.com 2023-03-18 00:40 出处:网络
Is there simple way to parse the binary plist file into the NSDictionary representation? I am searching something like that:

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号