Declan McKenna
Declan McKenna

Reputation: 4870

How do I test Persistent Memory using Xcode's iPhone Simulator

I have an NSMutableArray of custom objects saved to persistent memory like so:

- (void)applicationDidEnterBackground:(UIApplication *)application
{
        [NSKeyedArchiver archiveRootObject:[PlayerMenuController savedPlayers] toFile:@"/Users/Dec/Library/Application Support/iPhone Simulator/6.0/Applications/9BC31B2A-/savedPlayers"];
}

Which are loaded then tested as seen below:

NSMutableArray *loadedArray = [NSKeyedUnarchiver unarchiveObjectWithFile:@"/Users/Dec/Library/Application Support/iPhone Simulator/6.0/Applications/9BC31B2A-/savedPlayers"];
if (loadedArray != nil)
{
    [[PlayerMenuController savedPlayers] setArray:loadedArray];
}


for (int i = 0; i < [[PlayerMenuController savedPlayers] count]; i++)
{
    Player *p = [[PlayerMenuController savedPlayers] objectAtIndex:i];
    NSLog(@"%@ %u",[p getName],[p getSaveId]);
}
NSLog(@"%u",[[PlayerMenuController savedPlayers] count]);

To test this I open my app, save a few objects in to the array, minimise the app then close the application via the task manager/double clicking home. When I open my app again it appears the debugger as detached, none of my break points or NSLogs are called.

How do I go about debugging my app over multiple uses so i can test my apps ability to save and load data?

Upvotes: 0

Views: 744

Answers (2)

Marcus Adams
Marcus Adams

Reputation: 53860

Just run the app in debug mode again via XCode. Don't run it by clicking on the app icon on the simulator. If you don't change the code, it won't rebuild. You'll have the same bundle and settings.

Also, press the Stop button in XCode to stop the app rather than shutting it down in the simulator.

Upvotes: 1

Ares
Ares

Reputation: 5903

You can look at the simulators "content" on:

~/Library/Application Support/iPhone Simulator/

Then you will have to guess your apps directory by going into each one of them. Then look under the Documents folder. Your plist should be there.

Upvotes: 0

Related Questions