Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cpuin

macrumors member
Original poster
Feb 3, 2013
77
0
I have two Entities - Documents and Contragents

Documents has:

- kind str
- name str
- date Date
- contragent -> relation to Contragents

Contragents has:

- name str
- address str
- vat str
- document -> relation to Document
_________________________________

The GUI is very simple:

a tableview where are displayed all Contragents records

3 textfields where user input Contragents's name, address, vat

a button - where is pressed my code creates new Document.

THE QUESTION:

How can i bind(set, make) the selected contragent from the table to point to the Document i create with the button?

Here is my code:

Code:
//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];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.