-1

I am quite new at Objective-C programming, I was asked to develop a framework that could be implemented in IOS apps. This framework has three methods (that take a model object as an argument) that perform API comsumption and return a message (that takes from response). The problem is that I was asked to store the module parameters in plist, and I don´t have a good clue what this means. I been reading about plist and I know they can store serialized objects. But I really don´t understand what it means to be storing all parameters on this file.

Rafael
  • 117
  • 1
  • 9

1 Answers1

0

A plist is essentially a dictionary (or NSDictionary) -- with keys and values -- written to a specific file format that iOS expects.

To write a plist file is easy when you do it from Xcode. In Xcode 10.3 you can go to "File" -> "New" --> "File..." and select "Property List" from the types of files you see: File->New->File->PropertyList

I created a file (as an example) named "SomeFile.plist" and then added a couple keys & values to it:

New Plist File

Now after you get this file included in your new project, you need to read the keys & values back in. Here is a related question that shows you different ways to read the plist / dictionary, such as:

NSString *path = [[NSBundle mainBundle] pathForResource: @"YourPLIST" ofType: @"plist"]; 
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path];
NSString *name = [dict stringForKey: @"RaphaelName"];
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Note that the root of a plist can also be an array, not just a dictionary. – rmaddy Oct 06 '19 at 15:26
  • Thank you very much. The releated post mention that he is storing a String object in a plist, then using it when needed, but my question is, what is the usefulness of storing values instead o getting directly from code ?, I am sorry I never seen this aproach before, that is what I am curious about. – Rafael Oct 06 '19 at 16:38