I’m new to development and Im trying to create a simple dictionary app for personal use on the iPhone. For context, my question is a follow up to this one that some of you were kind enough to answer yesterday.
Is it possible to create a method that:
- Reads a text file
- Converts text strings in the file to NSStrings
- Populates an NSArray with the NSStrings to create an arrayWithObjects
Any help or example code would be greatly appreciated!
Formatting the text file to be a useful data structure and parsing it would be the hardest part. But, as long as your
NSArrayorNSDictionarycontain onlyplistserializable objects, likeNSStrings consider just using simple serialization.You could use this to save: (Where array is the array to save and path is an NSString of the file path)
And this to load from the file:
You could also use
NSJSONSerializationto create and structured string and save it through more general means.