table.plist에서 행 삽입, 삭제 및 순서 변경과 같은 몇 가지 변경 사항을 수행하여 viewDidDisappear에서 기본값으로 변경됩니다.Plist에 쓰여진 데이터가 저장되지 않습니다.
다음 코드를 시도했습니다.
-(NSString *)dataFilePath{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataFile = [documentsDirectory stringByAppendingPathComponent:@"ETCategoryList.plist"];
return dataFile;
}
//Code for deleting.
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleDelete){
[[self categoriesArray]removeObjectAtIndex:[indexPath row]];
NSArray *indexPathsToRemove = [NSArray arrayWithObject:indexPath];
[tableView deleteRowsAtIndexPaths:indexPathsToRemove withRowAnimation:UITableViewRowAnimationLeft];
[tableView reloadData];
NSArray *revisedArray = [[NSArray alloc]initWithArray:self.categoriesArray];
[revisedArray writeToFile:[self dataFilePath] atomically:YES];
}
}
plist에 저장하려는 코드를 표시하십시오. –
@AnoopVaidya 게시 된 코드의 마지막 줄입니다. – rmaddy
배열에 어떤 종류의 객체가 있습니까? – rmaddy