• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strange behaviour with NSTableView binded to NSArrayController with NSSet as content
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange behaviour with NSTableView binded to NSArrayController with NSSet as content


  • Subject: Re: Strange behaviour with NSTableView binded to NSArrayController with NSSet as content
  • From: Christian Ziegler <email@hidden>
  • Date: Tue, 3 Nov 2009 12:18:16 +0100


On 28.10.2009, at 05:29, Kyle Sluder wrote:

On Tue, Oct 27, 2009 at 11:27 AM, Christian Ziegler
<email@hidden> wrote:
I got an NSTableView binded to an NSArrayController (Values, Sort
Descriptors, Selection), which itself is binded to a class' NSMutableSet via
the ContentSet binding. The NSTableView is filled via Drag & Drop or
File/Open. For an initial insertion of data I set a sortDescriptor, but if
the user drags objects around in the NSTableView I remove the
sortDescriptors of the NSTableView by setting it to nil.

The fact that you have a sort descriptor set means the following will result in an NSArray being created somewhere. There's all sorts of magic (fast set proxies, slow set proxies, array proxies) that KVO presents based on what you're observing. I believe your code is starting out on the array path, but adding more things with no sort descriptor set triggers a change notification on your model object that KVO notices and therefore moves everything to the fast path, which provides no order information at all. NSTableView's binding support might notice this and not bother trying to reorder things, or it could try and KVO just silently drops the ball.

Without the AppKit source it's hard to know exactly what's going on,
but the conclusion is "You're Doing It Wrong."  You're arbitrarily
switching between having a concept of ordering and no concept of
ordering.  You need to always present an ordered collection to your
table view so that you can respect its desire to move things around.

--Kyle Sluder

Thanks for your reply!

Actually I thought thats what the arrangedObjects array is for. I only access the model through arrangedObjects. The reason why I use a Set is just because the objects dont have a natural ordering. The order in which the tableView presents the objects is just a matter of the view imo. Funny thing is, even after I added objects, the arrangedObjects array returns the correct object for each index. Im doin the moving objects around part myself, so I could debug which objects I fetch from the array.

Are you suggesting I should use an NSMutableArray as content instead of NSMutableSet?

Chris

_______________________________________________

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


  • Follow-Ups:
    • Re: Strange behaviour with NSTableView binded to NSArrayController with NSSet as content
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Linking Back to My CSS File.
  • Next by Date: Re: NSCollectionView and drag tolerance
  • Previous by thread: Re: Linking Back to My CSS File.
  • Next by thread: Re: Strange behaviour with NSTableView binded to NSArrayController with NSSet as content
  • Index(es):
    • Date
    • Thread