カテゴリのリストを含むテーブルビューがあります。テキストフィールドを含むアラートビューをポップする追加ボタンがあります。そのフィールドに入力されたテキストはテーブルビューに表示されます。ここまではすべて問題ありませんが、保存されません。プログラムでplistに追加する必要があると思います。誰かがそれを手伝ってくれますか?
//Reading data from plist.
NSString *categoryFile = [[NSBundle mainBundle]pathForResource:@"Categories" ofType:@"plist"];
self.categoryList = [[NSMutableArray alloc]initWithContentsOfFile:categoryFile];
//adding to the tableView
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 1)
{
UITextField *newCategoryName = [alertView textFieldAtIndex:0];
NSInteger section = 0;
NSInteger row = 0;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
NSString *extraContent = newCategoryName.text;
[[self categoryList]insertObject:extraContent atIndex:row];
NSArray *indexPathsToInsert = [NSArray arrayWithObject:indexPath];
[[self tableOfCategories]insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:UITableViewRowAnimationRight];
NSLog(@"%@",newCategoryName.text);
}
}