我想从我的.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; }
Abizern.. 6
NSString *string = savedStock[@"MemoriesDictionary"][@"Memory1"][@"Event1"][@"EventName"];
编辑
你也可以改写:
int iMemCount; iMemCount = [[savedStock objectForKey:@"MemoryCount"] intValue];
如
NSInteger iMemCount; iMemCount = [savedStock[@"MemoryCount"] integerValue];
你真的应该考虑在64位处理器上运行的您的iOS代码的可能性,并使用相应平台的安全类型(NSInteger
,CGFloat
,CFIndex
等)
NSString *string = savedStock[@"MemoriesDictionary"][@"Memory1"][@"Event1"][@"EventName"];
编辑
你也可以改写:
int iMemCount; iMemCount = [[savedStock objectForKey:@"MemoryCount"] intValue];
如
NSInteger iMemCount; iMemCount = [savedStock[@"MemoryCount"] integerValue];
你真的应该考虑在64位处理器上运行的您的iOS代码的可能性,并使用相应平台的安全类型(NSInteger
,CGFloat
,CFIndex
等)