• 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: Read-only NSTableView bindings - forcing update
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read-only NSTableView bindings - forcing update


  • Subject: Re: Read-only NSTableView bindings - forcing update
  • From: Andrew White <email@hidden>
  • Date: Wed, 11 May 2005 13:36:29 +1000


mmalcolm crawford wrote:

<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html> "Programmatic modifications to arrays not noticed by table view"

I'd [finally] distilled that from the Cocoa docs, but it's nice to have a clearer confirmation.


Can you perhaps help me with the opposite direction?

Consider:

@interface Element (MyExample)

- (unsigned int) myId;
- (NSString *) label;

- (void) setLabel: (NSString *) label;

@end

The call to myEntries returns an NSArray * of these beasties. As can be seen, myId is immutable while label is mutable. The total number of entries is also immutable.

When a change is made to an element, I want to propagate the change to data structures elsewhere in the system. I don't really want to do this in setLabel:, since Element is just a container and shouldn't know about how the data is being used.

Pre-bindings, I'd add code to tableView:setObjectValue:forTableColumn:row: to both change the value of Element (using setLabel) and trigger changes in the object controller / document to update the rest of the system.

Using bindings, is there an easy way to add a hook to the document so that changing the label of an Element also triggers this hook? I presume it's got something to do with addObserver:forKeyPath:options:context but I'm not quite sure how to do it cleanly.

If it makes a difference, my data is modelled in IB as:

File's Owner (MyDocument)
	property: myEntries

DataObject (NSObjectController)
	content: File's owner

ArrayController (NSArrayController)
	binding: contentArray = selection.myEntries [DataObject]

The array controller is chained to the File's Owner via an NSObjectController. Is this even necessary or can I connect the array object directly to the File's Owner?

Thanks for all your help.

--
Andrew White

--------------------------------------------------------------------------
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
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: 
 >Read-only NSTableView bindings - forcing update (From: Andrew White <email@hidden>)
 >Re: Read-only NSTableView bindings - forcing update (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: DocoaBrowser for 10.4?
  • Next by Date: Re: Q: NSTableView not sorting edited rows
  • Previous by thread: Re: Read-only NSTableView bindings - forcing update
  • Next by thread: NSTableView bound to array of NSString
  • Index(es):
    • Date
    • Thread