Pregunta

I have two Entities. Customers and Documents.

In a table the user selects the Customer.Below i create new Document object and one of the value i have to add is the ID of the Customer.I don't know how to access the value of selected object in array controller of Customers entity.

¿Fue útil?

Solución

The array controller's -selectedObjects will give you the array of Customer objects currently selected. There might just be one, or you could have several.

To get to the array controller programmatically, you'll need an IBOutlet. Set this up just like any other object in Interface Builder. The easiest way is with the Assistant Editor, viewing XIB and the XIB controller's header file: control drag from the array controller to the header, and then name your outlet.

Your comment about adding the Customer ID to the new Document object makes me think that your data model is incorrect. It sounds like you should have a relationship between Document and Customer. If you do that, you don't need the Customer ID too. Just follow the relationship keypath: thisDocument.customer.ID.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top