私はplistにデータをコピーするのにこのコードを試しましたが、追加する場合には機能しません。いずれにしてもデータを追加するには良い方法がありますか?
NSMutableDictionary * nameDictionary = [NSMutableDictionary dictionary];plistファイルにデータを追加するのに手伝ってもらえますか?
NSString *plistPath=[[NSBundle mainBundle] pathForResource:@"listNew" ofType:@"plist"];
[nameDictionary setValue:nameEntered.text forKey:@"name"];
[nameDictionary setValue:company.text forKey:@"company"];
[nameDictionary setValue:designation.text forKey:@"designation"];
// create dictionary with values in UITextFields
NSMutableArray *plist = [NSMutableArray arrayWithContentsOfFile:plistPath];
if (plist == nil) plist = [NSMutableArray array];
[plist addObject:nameDictionary];
[plist writeToFile:plistPath atomically:YES];
UIAlertView *tellErr = [[UIAlertView alloc] initWithTitle:title message:@"succsefully created" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[tellErr show];
[email protected]"";
[email protected]"";
[email protected]"";
あなたはそれが機能していないと言ったら、クラッシュしていますか、アレイには最後に追加する予定の辞書がありませんか?私が見ていることから、上記のコードは上手く見えます。 – Sam
初めてplistからデータ全体を削除しようとしたとき、またはリストを表示してから挿入しようとするとクラッシュする – ashwin19
質問に答えがある場合は緑色のチェック –