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 21:24:38 +0100
Y
On Dec 17, 2009, at 9:10 PM, Quincey Morris wrote:
> On Dec 17, 2009, at 11:58, Gustavo Pizano wrote:
>
>> In IB, I have 2 NSArrayControllers, one for the NSTableView that will add Items (ItemXInvoice) without prefetching, and one that will display a drop down button with the description of the existing Items (prefetching the existing ones), so if I select form that list and click the "use selected" I will create the ItemXInvoice and related with the selection, then add it to the NSArrayController of the NSTableView, (**)
>>
>> I have just realized what you meant by not using the add of the NSArrayController, ofr the case I want to create a new Item (ItemXInvoice), I must do it also in my own IBAction, creating the proper objects relate them and add them to the array controller.
>>
>> Now.. for (**).. when saving there shouldn't be any problems like duplicates Items, isn't it? because the Item exist already then just saves the ItemXInvoice and its relation to the existing Item...
>
> Yes, in your own action method you can control whether or not a new Item is created, then create your new ItemXInvoice, then link your ItemXInvoice to the correct Item, then add the ItemXInvoice to the data model (one way or another). Easy. :)
>
> I still think your user interface sounds a bit painful, because there seem to be 2 ways to create new invoice items. Could you arrange to add a "new item description" entry to the list of existing Items, so that creating a new invoice item is *always* done from the same place?
Yes Of course, I can set a "New Item" in the list, so then I can open a new window where I can fill in the description and the unitPrice. and save it.... thats good idea.. thanks :D
>
> Also, if you you a NSPopUpButton in pull-down mode instead of pop-up mode, you don't need a separate "Use Selected" button -- just choosing from the pull-down menu would initiate the creation action, saving a step, yes?
>
>
AHA Ok thats good.. just forgive me,.. I come form a WebObject-EOF background, and sometimes I still think in that way.
I was checking the documentation, just in case, Im not saying I will do it this way, but jsut to keep it in mind... Subclassing NSArrayController, and overriding add: method, I can get the entityName form the NSObjectController (Parent of NSArrayController), and create there the Instance of ItemXInvoice an Item, relate them and do as the doc says: " .... and sets it as the receiver’s content object using addObject:."
That way shall work isn't it? just that in IB I must set the EntityName and the ManagedObjectContext....
G.
Thanks for the HElp.. :D:D:..
> _______________________________________________
>
> 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