2012-04-13 7 views
0

私は多くの時間を苦労しています。NSString変数をplistファイルに追加する際にエラーが発生しました

[data_appoのsetObject: "文字列値" forKey:@ [NSStringのstringWithFormat:@ "%I"、(I-1、私はplistファイルにレコードを追加するために、次のコード行を使用してい

)]];

です。正常に動作します。次のように、ファイルから文字列を読み込もうとすると(別のキーで値を複製する必要があります)

NSString * string_appo = [data_appo objectForKey:[NSString stringWithFormat:@ "%i" 、j]];

[data_appo setObject:string_appo forKey:[NSString stringWithFormat:@ "%i"、(i-1)]];

はその後、私は

任意のアイデアERROR_EXECとアプリがクラッシュ...

をGEST ???

助けていただければ幸いです。

ありがとうございます!

答えて

0

追加した後、plistファイルを保存しましたか?私はこれをたくさんして、このようにします。

 //find the plist file 
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
     NSString *documentsDirectory = [paths objectAtIndex:0]; 
     NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Notes.plist"]; 
    //set the value for the key 
     [notesData setValue:textView.text forKey:[NSString stringWithFormat:@"General notes %d",selectedIndex]]; 
    //save the plist file 
     [notesData writeToFile: path atomically:YES]; 
    //relese and reload it 
     [notesData release]; 
     notesData = [[NSMutableDictionary alloc] initWithContentsOfFile: path]; 

私はこれが助けてくれることを願っています!

関連する問題