Skip to content

Instantly share code, notes, and snippets.

@abrahamjso
Created May 24, 2012 04:42
Show Gist options
  • Save abrahamjso/2779486 to your computer and use it in GitHub Desktop.
Save abrahamjso/2779486 to your computer and use it in GitHub Desktop.
read plist iOS
-(void)plistVista
{
NSString *path = [[NSBundle mainBundle] bundlePath]; //inicializamos el path
NSString *plistName = @"vistas.plist"; //Guardamos la direccion del archivo a leer
NSString *finalPath = [path stringByAppendingPathComponent:plistName]; //Leemos la direccion,
//guardandola en un string
NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:finalPath]; //inicializamos el diccionario
int cplistData = plistData.count; //Contamos las filas que contiene nuestro plis de nodo padre
//Essto nos servira para leer cada linea
for(int i = 0; i < cplistData; i++) //Inicializamos el for para su lectura
{
NSDictionary *vistaMenu = [plistData objectForKey:[NSString stringWithFormat:@"v%d", i+1]]; //Abrimos el
//diccionario que tiene como nombre v[numero de la lista]
NSString *nombreVista = [vistaMenu objectForKey:@"nombre"]; //Guardamos el valor en la variable
NSLog(@"%@", nombreVista); //La imprimimos
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment