iOS plist iOS Example:


1. Static data to be used in app.

To save static data in plist follow these methods:

a) Add a new file

enter image description here

b) Click Property list in Resources

enter image description here

c) Name the propertylist and a file will be created as(data.plist here)

enter image description here

d) You can create a plist of Arrays and Dictionaries as:

enter image description here

// Read plist from bundle and get Root Dictionary out of it

NSDictionary *dictRoot = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]];

// Your dictionary contains an array of dictionary // Now pull an Array out of it.

NSArray *arrayList = [NSArray arrayWithArray:[dictRoot objectForKey:@"Object1"]];

for(int i=0; i< [arrayList count]; i++)
    NSMutableDictionary *details=[arrayList objectAtIndex:i];