NSTreeController 添加新/选择/可编辑对象问题
我有一个 NSOutlineView 备份的 NSTreeController,它从 NSManagedObjectContext 获取数据,除了插入新对象之外,一切都很完美。
我想插入一个新对象,然后立即将焦点放在它上面并使其可编辑。
如果我通过以下方式创建一个新的 NSManagedObject:
Obj *p = [NSEntityDescription insertNewObjectForEntityForName:@"Obj"
inManagedObjectContext:[self managedObjectContext]];
它会立即插入,但我似乎无法选择它并获取它。
现在,如果我通过它插入它,
NSUInteger pathSource[2] = {0, 0};
[self.projectTreeController insertObject:p
atArrangedObjectIndexPath:[NSIndexPath indexPathWithIndexes:pathSource length:2]];
它会立即被选中,并且我可以使其可编辑。
问题是我不能使用这两种方法(我看到重复的条目),并且在不首先使用#1 的情况下无法使用方法#2。
理想情况下,我想使用方法#2,但不重复条目。
那么,插入/添加由 Core Data 备份的新对象的首选方法是什么?
I've got a NSOutlineView backed up NSTreeController which is getting data from an NSManagedObjectContext and everything works perfect except inserting new objects.
I want to insert a new object, then immediately put focus on it and make it editable.
If I create a new NSManagedObject via:
Obj *p = [NSEntityDescription insertNewObjectForEntityForName:@"Obj"
inManagedObjectContext:[self managedObjectContext]];
it gets immediately inserted but I can't seem to select it and get it.
Now, if I insert it via
NSUInteger pathSource[2] = {0, 0};
[self.projectTreeController insertObject:p
atArrangedObjectIndexPath:[NSIndexPath indexPathWithIndexes:pathSource length:2]];
It's immediately selected and I can make it editable.
The problem is that I cannot use both methods (I see double entries), and can't use method #2 without first using #1.
Ideally, I'd like to use method #2 but without making duplicate entries.
So, what's the preferred way to insert/add a new object that's backed up by Core Data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论