Re: Binding multiple NSTableView and NSPopupButton to an NSArrayControler
Re: Binding multiple NSTableView and NSPopupButton to an NSArrayControler
- Subject: Re: Binding multiple NSTableView and NSPopupButton to an NSArrayControler
- From: Lorenzo Thurman <email@hidden>
- Date: Mon, 02 May 2011 10:02:20 -0500
On Fri, Apr 29, 2011 at 3:18 PM, Quincey Morris <email@hidden
> wrote:
> Your description of the problem is a bit fuzzy. Let me nitpick at your
> description -- it may be that if you straighten out your terminology you'll
> solve your problem:
>
> On Apr 29, 2011, at 12:56, Lorenzo Thurman wrote:
>
> > I have an NSTableView column bound to an NSArrayController which itself
> > is bound to an NSMutableArray.
>
> No, it's not bound to a NSMutableArray. It's bound to an array *property*
> of some object. If the array controller is in the XIB file, it's typically
> bound to one of File's Owner's properties.
>
> > The mutable array resides in a different XIB.
>
> Almost certainly not. At least, I hope not. Why would you put a mutable
> array in a XIB? A mutable array is likely used as the backing store of an
> array property of an object in your data model (or possibly of a controller
> object).
>
> > The data is displayed as expected, but when I remove an item, although it
> > does disappear from the table, the
> > change is not written to disk when the application quits. I use
> > NSKeyedArchiver to persist the array to disk upon quitting. When the
> > application quits, the original array including the removed items is
> > written to disk.
>
> Which array? We haven't actually located the array yet. You might
> inadvertently have 2 arrays where you only intend there to be one.
>
> > I did some debugging and found that after the items are removed from the
> > array controller, the underlying array does indeed reflect the removal,
> > but something happens between there and quitting the application that
> > brings the removed items back into the array.
>
> Another possibility is that you really did put an array into a XIB, which
> means the *same* array contents will be reloaded from the XIB every time
> that XIB is loaded. Are you sure "the array" isn't being written correctly
> to your persistent store? Perhaps it is, but the written value isn't being
> reloaded next time?
>
> > My application also uses an NSPopupButton to display these same items.
>
> Is this just additional information, or are you saying there's an issue
> with the the popup button too?
>
>
> My apologies for not being clearer. I spent some time over the weekend, but
still couldn't figure it out, so here goes:
I have an NSPopupButton whose content is bound to an NSArrayController's
(controller A) arrangeObjects controller Key. This NSArrayController is
bound to an NSMutableArray which holds the items for display. The contents
of the NSPopuButton display as expected.
In another XIB (NSWindowController subclass), I have an NSTableView whose
only column's value is bound to an NSArrayController's (controller B)
arrangedObjects. This NSArrayController resides in the same XIB as the
NSTableView and is bound via an NSObject proxy in that same XIB to the same
NSMutableArray as controller A. These items display as expected in the
NSTableView. I can remove an item from the NSTableView, and in the debugger,
I can see that the item is indeed removed from the NSMutableArray. But when
I save the array on quitting the application, I see the removed item has
somehow made it back into the array.
I've also noticed that the NSPopupButton continues to display the removed
item. I would expect it would have updated itself, but clearly, I'm missing
something.
Thx
--
"My break-dancing days are over, but there's always the funky chicken"
--The Full Monty
_______________________________________________
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