.plist 파일이 있습니다. plist에 데이터를 쓸 때 추가하지 않지만 이전 내용을 덮어 씁니다. 여기 plist에 데이터를 추가하는 방법은 무엇입니까?
내 코드는
, 그것은 이전에 추가됩니다하고 덮어 쓰지 않도록 PLIST에 데이터를 기록하는 방법// 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:@"HistoryList.plist"];
// set the variables to the values in the text fields
NSString *str=[NSString stringWithFormat:@" %@ %@ %@",strname.text,strnum.text,selectfield.text];
self.historyArray = str;
// create dictionary with values in UITextFields
NSDictionary *plistDict = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects: historyArray, nil] forKeys:[NSArray arrayWithObjects: @"Name", nil]];
NSString *error = nil;
// create NSData from dictionary
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
// check is plistData exists
if(plistData)
{
// write plistData to our Data.plist file
[plistData writeToFile:plistPath atomically:YES];
}
else
{
NSLog(@"Error in saveData: %@", error);
}
?
http://stackoverflow.com/questions 새 항목 사전을 수정 사전
@Bhumeshwerkatre 그래서 그냥 코멘트를하기보다는 질문을 닫으십시오. – trojanfoe
@ user3040536 http://ipgames.wordpress.com/tutorials/writeread-data-to-plist-file/ 위의 링크를 확인하면 도움이 될 수 있습니다. –