views:

24

answers:

2

I just finished an app that allowed users to store lists of serial numbers in a tableview. The way the app stores the numbers is by storing in an NSMutableDictionary then writing to a persistence plist file. The app ran perfectly fine during testing.

However, I just built and packaged the app for ad-hoc distribution, and now when I test the app from an end-user perspective, the data is not being saved, i.e. when I add a new row to my tableview and typing in a new number, the new row is not being created and nothing is being written to the dictionary. I use the following code to write to the plist (assuming dict is already populated):

[dict writeToFile:[appDelegate dataFilePath] atomically:YES];

where in my App Delegate:

- (NSString *)dataFilePath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return [documentsDirectory stringByAppendingPathComponent:kFilename];
}

And I read the plist from disk using this:

NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:[appDelegate dataFilePath]];

What's wrong here?

A: 

If you say you're having trouble persisting data, you really should show the code where you write this plist file to disk, and also show the code where you load it from disk. Otherwise you're asking us to speculatively debug your code.

If you're doing it inside the application bundle, that is an example of an operation that will work in the Simulator, but not when run on a device.

Shaggy Frog
Alright, I added the relevant code. Does it help?
isaaclimdc
A: 

Oh I realize something. I did all my development using the 4.2 beta SDK and now running the app compiled using 4.1 as the base, the data doesn't seem to persist! Is there something new in 4.2 that does this?

isaaclimdc