How can I get this Objective-C object in a local file?

advertisements

I've got an iPhone app that loads a bunch of TableViews. The first time a user loads the app it downloads .json from a remote server, parses that into a NSDictionary and saves it locally on the device as a .plist.

Unfortunately, I can't figure out how to do a reloadTable on the MainWindow.xib after the data loads, so it sits blank until you exit and re-enter the application. I could either spend many hours trying to figure out how to reload the TableView or just pre-load the app with the .plist file. Presumably I just drop the file into the resource folder or something in XCode and that seems like the simpler option.

My problem is that since the data is stored in the .plist I can't just load the .json file I use on the server. What's the best way to create this .plist object in a local file? I wish I could just, you know, email it to myself or pull it from the device simulator or something, but that would be way to easy.


Yes, if you put a .plist file in the Resources folder in Xcode it will get built into the application. You find the path to it with something like:

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"];

You should in fact be able to grab a copy of the .plist file your app is creating from the simulator filesystem. Look inside:

~/Library/Application Support/iPhone Simulator/User/Applications/XXXXX/Documents

(where XXXXX is a really long random hex string).