2012-04-28 78 views

回答

15

试试这个:

NSString *path = [[NSBundle mainBundle] pathForResource:@"PlistX" ofType:@"plist"]; 
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path]; 
int number = [[[[dict objectForKey:@"One"] objectForKey:@"Two"]objectForKey:@"Three"] intValue]; 
NSLog(@"%d",number);  
3

1 NumberX =值)获取的数据(即NSMutableDictionary *)从plist保存到磁盘:

NSMutableDictionary *dictionary = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainers format:NULL errorDescription:&error]; 

2)从字典中检索需要的对象。

//in your case 
NSNumber *tmpNumber = [[[dictionary objectForKey:@"One"] objectForKey:@"Two"] objectForKey:@"Three"]; 
// convert to int 
int NumberX = [tmpNumber intValue]; 
+0

生病稍后再试此,感谢您的快速答复。 – akuritsu 2012-04-28 05:43:09