• 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
[BINDINGS] NSTableView vs. NSUserDefaultsController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BINDINGS] NSTableView vs. NSUserDefaultsController


  • Subject: [BINDINGS] NSTableView vs. NSUserDefaultsController
  • From: Des Courtney <email@hidden>
  • Date: Fri, 20 May 2005 23:05:50 -0500

Currently, I am working on a prefs dialog for an experimental
  Cocoa app.  (The same one I found the NSMovie memory leak on,
  FYI.)  So far, I made a pref window that mixes both
  NSUserDefaultsController/Bindings controls with a NSTableView
  that is using a data source, delegation, and an outlet
  connection to do its work, calling NSUserDefaults directly.
  The problem is that the above three objects are one and the same...
  a royal mix-up from a MVC perspective.  I'm trying to re-work
  the table view control to use the NSController and Cocoa bindings
  to make the entire dialog consistent.

The gist of what I'm trying to do: I'm populating the table view
  with a set of rows that contains several user visible columns
  and a hidden "column" that acts as a row ID for storage in the
  prefs file.  I've made an example app of what I've made so far
  while trying to figure out a pure-bindings way of doing things...

<http://users.ameritech.net/wormwood/BoundTable.zip>

This is what I've been able to accomplish, based on reading the
  mailing list archives, the bindings documentation, and examining
  what few bindings code examples I could find on the 'Net.
  (The best resource I've found, the mmalc Cocoa examples, includes
  every binding trick EXCEPT the very thing I'm trying to do,
  it seems like.)

- I've bound the table view to a NSArrayController.  This allowed
  me to remove the data source, but I still needed some code to
  populate the contents of this controller.  (My original data
  source was returning results dynamically, instead of from an
  array.)

- Each array entry is a dictionary with several keys, in my example,
  "colOne" is the value to display in the table view, "colTwo" is
  the value to store in the prefs file.

- I'm able to bind an NSObjectController to "values.storedValue"
  specifically, so I can display it's contents in an text field.
  To stuff a test value to display, you can type...

defaults write com.mac.wormwood.boundTable storedValue "Hidden pref #25"

...in the Terminal if you don't want the bottom field of the
  example app I provided to be blank.

- I've also bound another NSObjectController to "selection.colTwo"
  of the array controller.  I'm able to confirm (via a bind to a
  second text field) that this value is updated whenever I change
  the selection of the table view.  This allowed me to remove the
  delegate aspect of my "working" design.

Where I'm falling down at is how to link the "selection.colTwo"
  and "values.storedValue" objects together so that the table views
  row ID is stored in the prefs file.  I've tried connects, changing
  the bindings, and even manually copy/pasting the values between the
  two text fields (after making them editable) to figure out a way.

If my above explanation is still too vague, I can provide my "working"
  example.  But, I think what I've provided may already be more than
  what most list readers are willing to put up with.

Des


--
Des "Wormwood" Courtney     1 Little, 2 Little, 3 Little Endian
<mailto:email@hidden>      3 Big, 2 Big, 1 Big Endian
 _______________________________________________
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

  • Prev by Date: Re: CoreData and NSTextView
  • Next by Date: Re: Lots of NSTimers?
  • Previous by thread: Re: Online Help Creation in XCODE
  • Next by thread: Exclude files from backup
  • Index(es):
    • Date
    • Thread