2012-04-28 23 views

Respuesta

15

Prueba esto:

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) Obtener datos (es decir NSMutableDictionary *) de plist guardado en disco:

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

2) Recuperar el objeto necesario del diccionario.

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

mal tratar esto más adelante, gracias por la respuesta rápida. – akuritsu

Cuestiones relacionadas