Wie speichere ich einen Wert in einer Plist-Datei in iPhone?

Ich bin neu in der iPhone-Entwicklung. Ich verwende den folgenden Code, um den Wert zur Liste hinzuzufügen, aber wenn ich die Liste nach der Ausführung des Codes überprüfe, sehe ich keinen in der Liste gespeicherten Wert. Wohin gehe ich? Bitte helfen Sie mir. Die von mir erstellte Liste befindet sich im Ressourcenordner. Danke.

NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"regvalue.plist"];
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:finalPath];
[plistDict setValue:@"hello" forKey:@"choice"];
[plistDict writeToFile:finalPath atomically: YES];

Zum Abrufen des Wertes

NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"regvalue.plist"];
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:finalPath];
NSString *value;
value = [plistDict objectForKey:@"choice"];
NSLog(@"the value is %@",value);

It gibt nur Nullwert. Bitte helfen Sie mir heraus. Danke.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage