I've got a large amount of data stored in a CSV file. I can parse the file into a NSArray, but the process takes about 1 minute on the phone. I can then save this file to the phone using
[NSArray writeToFile:filePath atomically:YES]
Is it possible for me to save this NSArray to a file on the computer, and then only have to pull the NSArray from a file in the appBundle rather than have to parse it on the phone?
In other words, I have a massive CSV file that I want to convert to a file in the appBundle than can quickly be turned into an NSArray. I don't want the app to go out with the need for this file to be parsed at all. So how do I make a file that is readable by [NSArray initWithContentsOfFile:] from my CSV?
Yes you can, with some restrictions:
In iOS, the app bundle is read-only. You could build up this array and save it to your bundle as part of creating your app, but you could not do that at runtime.
I sometimes write code that creates files in the documents directory in the simulator, then manually copy the files out of the simulator's sandbox directory for my app and into the project.
If you want to build an array and save it to disk at runtime, you will need to save it to one of the allowed directories in your sandbox - probably the documents directory.
Saving your array to a file will only work if the entire "object graph" of objects contained in the array are all "property list objects" (NSString, NSData, NSDate, NSNumber, NSArray, or NSDictionary objects). You can have an array of dictionaries of arrays wit strings, numbers, data, dates, etc, in any combination, but if there is even 1 object down inside one of the other objects, the save will fail.
Another point:
The NSArray method writeToFile:atomically: converts your array to an XML property list file. Note that XML property lists are bigger and slower to save and load than binary property list files.
Take a look at the NSPropertyListSerialization class reference for info on saving an object to a binary property list, which is more compact and faster.