Re: Overriding NSArrayController to be used in a many-to-many RS and NSTable Bindings
Re: Overriding NSArrayController to be used in a many-to-many RS and NSTable Bindings
- Subject: Re: Overriding NSArrayController to be used in a many-to-many RS and NSTable Bindings
- From: Gustavo Pizano <email@hidden>
- Date: Thu, 17 Dec 2009 20:07:10 +0100
Quincey thanks for the reply.
In fact what I want is to allow the user to, create new Items, and use Exiting ones, in any case a new ItemXInvoice must be created somehose,...For the second option I had in mind, that once I select an exiting Item, then I click an "Use selected" button, this one will create a ItemXInvoice relate it to the selected Item and insert it into the NSArrayController which is bound to the NSTableView .... can this work?...
Gustavo
On Dec 17, 2009, at 7:16 PM, Quincey Morris wrote:
> On Dec 17, 2009, at 09:39, Gustavo Pizano wrote:
>
>> I have the follow entities and relations: Invoice< >> ItemXInvoice<< > Item.. The Entity ItemXInvoice has attributes quantity and totalItemPrice, and the Item has, descr (description) and unitPrice.
>>
>> An Instance of NSArrayController for the entity ItemXInvoice
>>
>> Now I have an NSTable, with 4 columns, Description, Quanity, Unit Price, and TotalPrice. and its model key path biding to:
>> Description Column : toItem.descr ,
>> Quantity : quantity.
>> UnitPrice: toItem.unitPrice
>> totalItemPrice: totalItemPrice.
>>
>> so when I click add, it creates a ManageObject ItemXInvoice and insert it into the NSArrayController, but of course when I try to put something in the columns, Description and UnitPrice, when I exit the field it disappear because the Item for that ItemXInvoice doesn't exist... (thats what I am thinking, am I right?).
>>
>> So I guessI have to implement a custom class of NSArrayController, and be this one the class for the Instance of the controller for ItemXItem, then override the method add, and there ... what shall I do?
>
> The key to this is "when I try to put something in the columns, Description and UnitPrice". Your NSTableView is creating an ItemXInvoice object, but it sounds like you really need to create an Item object.
>
> If your interface must provide the ability to create new items by typing into a new row of the table, you'll need some kind of mediating controller to handle the logic of creating both a new Item and a new ItemXInvoice for the addition.
>
> (Depending on the behavior you want, you might be able to get away with having ItemXInvoice's 'awakeFromInsert' method create a new Item too, but that leaves you without a way of creating a new ItemXInvoice using an existing Item. It's not clear what user interface you're expecting to use for that case.)
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden