Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 992
sekhar Avatar asked Oct 13 '10 08:10

sekhar


People also ask

What is info plist in iOS?

Every iOS app uses an Info. plist file to store configuration data in a place where the system can easily access it to determine things like what icon to display, what languages or document types to support, and many other important behaviors.

How do I edit info plist?

All you have to do is click on the blue project icon -on top of the left- and go to the “Build Settings” tab, search “Info. plist” and choose “Info. plist File” section. Then change the information of the section from your folder's name.

How do I save data in plist programmatically in Swift 5?

fileManager. fileExists(atPath: path)){ if let bundlePath = Bundle. main. path(forResource: "myData", ofType: "plist"){ let result = NSMutableDictionary(contentsOfFile: bundlePath) print("Bundle file myData.

How create plist file in iOS?

To create a plist file, it just as simple as creating a new class. Click menu File > New > File... ( ⌘ - CMD + N ).)


1 Answers

Here is a code sample:

NSString *path = [[NSBundle mainBundle] pathForResource: @"YourPLIST" ofType: @"plist"];  NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path]; id obj = [dict objectForKey: @"YourKey"]; 
like image 133
jv42 Avatar answered Oct 02 '22 12:10

jv42