Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="https://stackoverflow.com/questions/4075056/saving-data-in-ios">This answer</a> might help you. Using Core Data might be overkill here, and saving to a plist is extremely easy. This is Benoît's answer from the linked question:</p> <pre><code>NSString *error; NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *plistPath = [rootPath stringByAppendingPathComponent:@"yourFile.plist"]; NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:rootObj format:NSPropertyListXMLFormat_v1_0 errorDescription:&amp;error]; if(plistData) { [plistData writeToFile:plistPath atomically:YES]; } else { NSLog(@"Error : %@",error); [error release]; } </code></pre> <p>where <code>rootObj</code> is the object you wish to serialize, in this case, your array/dictionary. </p> <hr> <p>Also, if you are going to be read/writing to this data frequently during the course of your app, using a <a href="https://stackoverflow.com/questions/145154/what-does-your-objective-c-singleton-look-like">singleton</a> which can make a <em>huge</em> difference performance-wise instead of constantly reading/writing from/to a file. You can load all of your data into the singleton on app-launch and save it upon <code>applicationWillTerminate</code>.</p> <p>To answer your array/dictionary question, it depends on how you are obtaining your strings and how you want them to be ordered. Sorting an array is extremely easy, as you can see in <a href="https://stackoverflow.com/questions/1351182/how-to-sort-a-nsarray-alphabetically">this</a> answer.</p>
 

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