tags:

views:

25

answers:

1

this seems to work fine in the simulator but on the device the files are not being written.

here's the code.

-(void)saveOld{

NSArray *saveState = [NSArray arrayWithObjects:headArray,dropQArray,[NSNumber numberWithInt:dropLimit],[NSNumber numberWithInt:dropCount],[NSNumber numberWithInt:score],[NSNumber numberWithInt:level],[NSNumber numberWithInt:maxChain],nil];

NSMutableString *path = [[NSHomeDirectory() mutableCopy]autorelease];
[path appendString:@"/saveState"];

BOOL saved = [NSKeyedArchiver archiveRootObject:saveState toFile:path];
NSLog(@"did save state %d",saved);
path = [[NSHomeDirectory() mutableCopy]autorelease];
[path appendString:@"/isSaveState"];


saved = [NSKeyedArchiver archiveRootObject:[NSNumber numberWithBool:1] toFile:path];
NSLog(@"did save state %d",saved);
}
+1  A: 

There is no home directory on the iPhone :D

You should use this instead:

NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

This will give you the basic documents directory, append strings to it then.

tadej5553