• 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: NSMatrix / NSArrayController bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMatrix / NSArrayController bindings


  • Subject: Re: NSMatrix / NSArrayController bindings
  • From: Steven Kramer <email@hidden>
  • Date: Wed, 27 Oct 2004 20:22:25 +0200


Op 27-okt-04 om 19:22 heeft Byron Wright het volgende geschreven:

I figured it out, if I am not mistaken, the documentation is a little incorrect (or I am interpreting it incorrectly ) . I am doing the following to bind an NSMatrix subclass to an NSArrayController :

/* self = subclass on NSArrayController */
[myMatrix bind:@"content" toObject: self withKeyPath:@"arrangedObjects" options:nil];
[myMatrix bind:@"contentValues" toObject: self withKeyPath:@"arrangedObjects.name" options:nil];

This is the documentation on the NSMatrix bindings :

/ /---------------------------------------------------------------------- ---
http://developer.apple.com/documentation/Cocoa/Reference/ CocoaBindingsRef/BindingsText/NSMatrix.html


Reading this tells me that I must bind the content key of the NSMatrix to an NSArrayController. However, the only way I can get it to work is to bind it to the arrangedObjects key of the NSArrayController which returns an NSArray (not an NSArrayController). So I have it working but whenever I add objects to the NSArrayController I have to call "rearrangeObjects" to "touch" the controller so that the NSMatrix knows about these changes.


Aha. The answer is that you always bind to a controller key (like 'arrangedObjects', but there are others), so you're doing that the right way. If you use the NSArrayController methods (like addObject, removeObject, setContent) you will see that changes are reflected automatically. If, however, your subclass changes the content array directly itself, it must notify observers of the change. Calling rearrangeObjects is one way. So you're doing that the right way too.

Summarizing, I'd say you solved everything yourself and your solution even is the canonical one :-)

Steven

Met vriendelijke groeten,

Steven Kramer

--
email@hidden
http://sprintteam.com/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >NSMatrix / NSArrayController bindings (From: Byron Wright <email@hidden>)
 >Re: NSMatrix / NSArrayController bindings (From: Steven Kramer <email@hidden>)

  • Prev by Date: Re: setShouldCascadeWindows: Not Working
  • Next by Date: [ANN] Accessorizer update
  • Previous by thread: Re: NSMatrix / NSArrayController bindings
  • Next by thread: Re: NSMatrix / NSArrayController bindings
  • Index(es):
    • Date
    • Thread