私はplistを作成したアプリケーションを開発していますが、データを追加しています。しかし、データが上書きされるたびに前回のデータ失われます。私は、岩、1つの名前を追加すると仮定すると、次回は、岩を追加すると、岩が上書きされた岩、しかし、私が望むのは私のplistは両方の岩と岩などを含める必要があります...私はplistユーザーエントリは....ここplistにデータを動的に追加し、テーブルビューのセルを設定する
は
-(IBAction) myplist:(id) sender//the data is saved in a plist by clicking on this button
{
NSLog(@"mylist Clicked");
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:searchLabel.text];
// get paths from root direcory
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Data.plist"];
// This writes the array to a plist file. If this file does not already exist, it creates a new one.
[array writeToFile:plistPath atomically: TRUE];
}
ありがとうソニーそれは働いて..それまさに私が望んでいたものだった...しかし今、もう一つの問題はシミュレータで働いています。しかし、それをデバイス上で動かすにはどうすればいいですか? – Ranjit
こんにちは、私はplistに3つの値を追加したい場合、私はもう1つ質問したいと思います。そして、ユーザーがそれ以上を追加すると上書きされます...どうすればいいですか? – Ranjit