Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>IMHO, a simple way to achieve this is through plist.</p> <p>Here, a small example to achieve what you want.</p> <p><strong>1) Create your plist file.</strong></p> <p>In your project, go and "Add New File". In the left column, under iOS (for example), select "Resource". In the main panel select a "Property List" file. Save with a name like "Defs".</p> <p>Your plist should look like the following.</p> <p><img src="https://i.stack.imgur.com/MD1WB.png" alt="enter image description here"></p> <p><strong>2) Read the plist file</strong> (comments in the code)</p> <pre><code>- (void)readDefinitionsFile { // grab the path where the plist is located, this plist ships with the main app bundle NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Defs" ofType:@"plist"]; // create a dictionary starting from the plist you retrieved NSDictionary* definitions = [NSDictionary dictionaryWithContentsOfFile:plistPath]; // JUST FOR TEST PURPOSES, read the keys and the values associated with that dictionary for (NSString* key in [definitions allKeys]) { NSLog(@"definition for key \"%@\" is \"%@\"", key, [definitions objectForKey:key]); } } </code></pre> <p><strong>Some notes</strong></p> <p>Above a simple example on how to use plist. It does not provide a complete example to achieve what you want. Based on that you will be able to reach your goal.</p> <p>You should need a property to reference the dictionary you retrieved. So, for example, in your .m.</p> <pre><code>@interface ViewController () @property (nonatomic, strong) NSDictionary* definitions; @end @implementation ViewController // other code here // within readDefinitionsFile method self.definitions = [NSDictionary dictionaryWithContentsOfFile:plistPath]; </code></pre> <p>Use <code>definitions</code> to retrieve the definition you are interested in.</p> <pre><code>NSString* definition = [self.definitions objectForKey:@"aKeyYouWillRetrieveFromSomewhere"]; if(definition) { NSLog(@"definition is %@ for key %@", definition, @"aKeyYouWillRetrieveFromSomewhere"); } else { NSLog(@"no definition for key %@", @"aKeyYouWillRetrieveFromSomewhere"); } </code></pre> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload