no idea why, but this simply isn’t working. it’s supposed to load some values from a plist file, and load them into some UITextFields. it does output with the NSLogs everything you would expect, but but the text on the UITextFields aren’t the same. it almost seems as if its randomly choosing where to put what.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSMutableString stringWithFormat:@"%@.plist",file]];
NSDictionary *loadDict;
if([[NSFileManager defaultManager] fileExistsAtPath:filePath]){
NSLog(@"hey its there!");
loadDict = [[NSDictionary alloc] initWithContentsOfFile:filePath];
[numSidesBox setText:[loadDict valueForKey:@"numSides"]];
NSLog([loadDict valueForKey:@"numSides"]);
[numSidesBox setText:[loadDict valueForKey:@"numDice"]];
NSLog([loadDict valueForKey:@"numDice"]);
[numSidesBox setText:[loadDict valueForKey:@"modifier"]];
NSLog([loadDict valueForKey:@"modifier"]);
[numSidesBox setText:[loadDict valueForKey:@"numRolls"]];
NSLog([loadDict valueForKey:@"numRolls"]);
}
else{
NSLog(@"hey its not =(");
}
It appears that you are setting the text of the same text box again and again. So,
numSidesBoxshould always contain the text of[loadDict valueForKey:@"numRolls"]. I assume that you have more than one text field, so just changenumSidesBoxto the other variables likenumDiceBoxor whatever you call them.P.S. I would also suggest using
objectForKey:rather thanvalueForKey:.