Fox*_*Dev 1 cocoa objective-c ios
我想从我的.app目录中的plist中检索数据.我无法弄清楚如何获取子词典数据.例如,我想获得MemoriesDictionary/Memory1/Event1/EventName价值.

我可以通过以下方式获得MemoryCount价值iMemCount:
int iMemCount;
//Do file searching/getting for plist
NSString *plistDirectory = [[NSBundle mainBundle] pathForResource:@"memoryDetails" ofType:@"plist"];
NSLog(@"array: %@",plistDirectory);
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath: plistDirectory]) //4
{
NSLog(@"exists");
NSMutableDictionary *savedStock = [[NSMutableDictionary alloc] initWithContentsOfFile: plistDirectory];
iMemCount = [[savedStock objectForKey:@"MemoryCount"] intValue];
} else {
NSLog(@"Does Not Exist");
iMemCount = 0;
}
Run Code Online (Sandbox Code Playgroud)
NSString *string = savedStock[@"MemoriesDictionary"][@"Memory1"][@"Event1"][@"EventName"];
Run Code Online (Sandbox Code Playgroud)
编辑
你也可以改写:
int iMemCount;
iMemCount = [[savedStock objectForKey:@"MemoryCount"] intValue];
Run Code Online (Sandbox Code Playgroud)
如
NSInteger iMemCount;
iMemCount = [savedStock[@"MemoryCount"] integerValue];
Run Code Online (Sandbox Code Playgroud)
你真的应该考虑在64位处理器上运行的您的iOS代码的可能性,并使用相应平台的安全类型(NSInteger,CGFloat,CFIndex等)
| 归档时间: |
|
| 查看次数: |
1487 次 |
| 最近记录: |