我有三个实体——文件、合同和产品。
文档有:id - int64 contragentId - int64 paymentMethod - 字符串 documentDate - 日期 documentKind - 字符串
反对者有 id - int64 名称 - 字符串地址 - 字符串
产品有 id - int64 sku - 字符串 productQuantity - int64 描述 - 字符串 unitValue - 十进制 totalValue - 十进制 isTemp - Bool
我已经实现了 Products 子类化模型和 totalValue = quantity * unitValue
我想在另一个表中保留所有文档,但我不知道如何显示 Contragent.name 我应该使用该Document.contragentId = Contragent.id
- (IBAction) createDocument:(id)sender
{
//create new document
NSManagedObject *document = [NSEntityDescription
insertNewObjectForEntityForName:@"Documents"
inManagedObjectContext:self.managedObjectContext];
NSNumber *num = [NSNumber numberWithInteger: [_documentNumber integerValue]];
[document setValue: num forKey:@"id"];
[document setValue: [_documentKind stringValue] forKey:@"documentKind"];
[document setValue: [_documentDate dateValue] forKey:@"documentDate"];
[document setValue: [_paymentMethod stringValue] forKey:@"paymentMethod"];
[_documentNumber setIntegerValue:[_documentNumber integerValue]+1];
//get ID
//NSString *contragentId = [[_contragents selectedObjects] valueForKey:@"eik"];
//NSLog(@"The customer ID is: %@", contragentId);
document.contragent = [_contragents selectedObjects];