How to add and get the values from .plist in iOS

sekhar picture sekhar · Oct 13, 2010 · Viewed 22.5k times · Source

I am implementing a application based on web services. In that I need to add a string as property in .plist and I need to get the value from the .plist whenever I need in the code.

Answer

jv42 picture jv42 · Oct 13, 2010

Here is a code sample:

NSString *path = [[NSBundle mainBundle] pathForResource: @"YourPLIST" ofType: @"plist"]; 
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path];
id obj = [dict objectForKey: @"YourKey"];