我希望编辑核心数据中的现有记录。目前,我有这段代码,但它创建了一条新记录(并将正确的数据插入到正确的列中):
NSManagedObjectContext *context = [[NSApp delegate] managedObjectContext];
NSManagedObject *instrument = nil;
instrument = [NSEntityDescription insertNewObjectForEntityForName: @"Instrument"
inManagedObjectContext: context];
[instrument setValue:[NSNumber numberWithInt:quantityInStockInstruments]
forKey: @"quantity"];
结果将如下所示:
Instrument | Value | Quantity
Violin | £25 | 9
| | 8 <<< This is the new record that is created, instead of setting the
quantity of violin from '9' to '8'
我希望程序编辑当前突出显示的行的数量列(在这种情况下是“小提琴”行。我该怎么做?