プロパティリストファイルに保存しようとしましたが、オブジェクトを実際のファイル自体ではなく配列に保存するだけなので機能しません。つまり、保存したものが明らかに永続化されていません。
[[category objectAtIndex:questionCounter] replaceObjectAtIndex:5 withObject:myString];
[category writeToFile:filePath atomically:YES];
以前にこれを使用して、プロパティ リスト ファイルをドキュメント ディレクトリに保存し、編集して保存できるようにしました。
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *plistFilePath = [documentsDirectory stringByAppendingPathComponent:fileNameFull];
if([[NSFileManager defaultManager] fileExistsAtPath:plistFilePath]) {
category = [NSMutableArray arrayWithContentsOfFile:plistFilePath];
NSLog(@"Files exist.");
}
else {
filePath = [[NSBundle mainBundle] pathForResource:fileNamer ofType:@"plist"];
category = [NSMutableArray arrayWithContentsOfFile:filePath];
NSLog(@"Files have been created.");
}
プロパティ リストは配列で構成されており、それらの配列内にオブジェクト (文字列) を保存しようとしています。些細なことのような気がしますが、見分けがつきません。