핵심 데이터의 기존 레코드를 편집하고 싶습니다. 순간, 나는이 코드를 가지고 있지만, 새 레코드를 생성합니다 (올바른 컬럼에 올바른 데이터를 삽입) :NSManagedObject setValue 문제 (핵심 데이터)
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'
내가 원하는 프로그램이이 경우에 '바이올린'행입니다 현재 강조 표시된 행의 수량 열을, (편집 나는이
현재 강조 표시된 행을 업데이트하는 방법은 테이블에서 데이터를 가져 오는 방법에 따라 다릅니다. ArrayController/bindings 또는 데이터 소스를 사용하고 있습니까? – amrox
엔티티 : instrument가있는 NSArrayController에 테이블을 바인딩하고 있습니다. 계측기 엔티티는 핵심 데이터 모델에 있습니다. btw, 나는 실제로이 NSArrayController에 해당하는 .h 및 .m 파일이 없습니다. – Michael