• 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: Table views with different NSArrayControllers sharing the same data object...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Table views with different NSArrayControllers sharing the same data object...


  • Subject: Re: Table views with different NSArrayControllers sharing the same data object...
  • From: Adam P Jenkins <email@hidden>
  • Date: Wed, 27 Feb 2008 21:27:06 -0500

If the content array is itself a property of another object, and the object containing the array property has indexed accessors for the array property, then observers of the array property will be notified of objects being added, removed or replaced in the array in addition to the whole array being replaced. So for example if you had a Course class with a "students" property, and you wrote indexed accessors for the students property, then observers of a Course object's students property would be notified if students are added or deleted. So you could setup an observer to add observers for newly added student objects.

See here for more info on indexed accessors: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html



On Feb 27, 2008, at 7:34 PM, Keith Blount wrote:

Hi,




I'm in the process of putting together a small list view based on an NSTableView. It's pretty simple - just a table of data using an NSArrayController, with a data object that provides the array. However, in my app it is possible that the view may appear in a split view with a copy of itself in the other view (if the user has split the view and selected the same list view for both views). This means that, if the user makes edits to the table in one view, it should automatically be updated in the table in the other view.





What is the best way of setting this up? What I've tried so far is less than perfect. I bind both views/table controllers to the same underlying data object (array). My -setContent: method in my view object sets up observers on all the objects in that array. Still, when -addObject: gets called on one of the tableControllers, this adds an object that the other table controller (controlling the other view) doesn't know about... Obviously, when -adObject gets called, -setContents: isn't called (because the controller's content array isn't actually changed) so the other view doesn't get updated.





Essentially, I want my two table views to act much as two text views would that share the same underlying text storage. If anyone could give me advice on the best way to achieve this, I would be very grateful.





Many thanks and all the best,

Keith




____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
_______________________________________________


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

_______________________________________________

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


References: 
 >Table views with different NSArrayControllers sharing the same data object... (From: Keith Blount <email@hidden>)

  • Prev by Date: Re: Drawing from secondary thread erases resize corner in window?
  • Next by Date: Endless Hang on Saving a Core Data Document
  • Previous by thread: Table views with different NSArrayControllers sharing the same data object...
  • Next by thread: Endless Hang on Saving a Core Data Document
  • Index(es):
    • Date
    • Thread