我得到的值是从plist中排序并显示在tableview
中的值。我正在提供输入将写入plist的自定义类别的功能。但我希望按照排序的字母顺序插入。有人可以建议我如何获得必须插入的行的indexpath
。我已经使用了下面的代码,自定义项将在0位置在Sorted Array中获取IndexPath
NSInteger section = 0;
NSInteger row = 0;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
NSDictionary *categoryDictionary = [NSMutableDictionary dictionary];
[categoryDictionary setValue:newCategoryName forKey:@"name" ];
[categoryDictionary setValue:@"custom.png" forKey:@"image"];
[[self categoriesArray]insertObject:categoryDictionary atIndex:row];
[[self categoriesArray] writeToFile:[self dataFilePath] atomically:YES];
NSArray *indexPathsToInsert = [NSArray arrayWithObject:indexPath];
[[self tableView]insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:UITableViewRowAnimationRight];
[self.categoriesArray writeToFile:[self dataFilePath] atomically:YES];
***终止应用程序由于未捕获的异常“NSUnknownKeyException”,原因:'[<__ NSCFString 0x8b7e580> valueForUndefinedKey:]:这个类不是关键字编码密钥值。“ – 2013-04-24 06:46:47
当使用排序描述符时,我得到了上述错误 – 2013-04-24 06:47:42
@ChandraSekhar你可以把断点,告诉我你的代码破坏的地方。 self.categoriesArray只包含字典对象,它们都有一个关键的“名称”,我假设这些都是这样的。请检查,以及 – Anupdas 2013-04-24 06:56:55