Store a large list of static strings (Swift)
I am making an iOS 8 app with Swift. I need to store long lists of strings. They must be read at any time during the application. What's the easiest way to do this? XML files, text files, binaries?
+3
quemeful
source
to share
1 answer
Usual Objective-C experience is used. You can actually use any of the methods you describe. Some comments:
- XML: seems like overkill. You will need a parser, etc.
- Exception: Apple property lists (which is also XML format). You can read the entire list with one layer
- Plain text: contains multiple lines of code to read it, so it might be viable. It would be especially easy to make the list in the first place (e.g. using excel or a text editor).
- Binary: not recommended for strings.
- Core Data: Stores rows in a neat SQLite database, but would probably be overkill as well.
eg. for plist:
let wordList = NSArray(contentsOfFile: path)
+2
Mundi
source
to share