Alright, I want to write the username that is input into the text box onto the disk so it's saved.
I've found this function at the iPhone Dev Center
But I am unsure what to pass as the first parameter? this converts the plist to a data form to be saved, but what can I do to make my plist programatically?
I've already got the path stored in the variable sSettingsPath where I will write the data to.
I've also found this function, which would be better?
I want to store the username, and then other ints containing details about the character the user will be using in the game.
Other function:
Any idea's? Thanks.
I've found this function at the iPhone Dev Center
Code:
- (BOOL)writeApplicationPlist:(id)plist toFile:(NSString *)fileName {
NSString *error;
NSData *pData = [NSPropertyListSerialization dataFromPropertyList:plist format:NSPropertyListBinaryFormat_v1_0 errorDescription:&error];
if (!pData) {
NSLog(@"%@", error);
return NO;
}
return ([self writeApplicationData:pData toFile:(NSString *)fileName]);
}
But I am unsure what to pass as the first parameter? this converts the plist to a data form to be saved, but what can I do to make my plist programatically?
I've already got the path stored in the variable sSettingsPath where I will write the data to.
I've also found this function, which would be better?
I want to store the username, and then other ints containing details about the character the user will be using in the game.
Other function:
Code:
- (BOOL)writeApplicationData:(NSData *)data toFile:(NSString *)fileName {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
if (!documentsDirectory) {
NSLog(@"Documents directory not found!");
return NO;
}
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName];
return ([data writeToFile:appFile atomically:YES]);
}
Any idea's? Thanks.