• 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: binding to number of selected rows in a table [solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: binding to number of selected rows in a table [solved]


  • Subject: Re: binding to number of selected rows in a table [solved]
  • From: James Walker <email@hidden>
  • Date: Wed, 04 Mar 2009 18:33:35 -0800

Jerry Krinock wrote:

On 2009 Mar 04, at 11:39, James Walker wrote:

* Add an NSMutableIndexSet* member to my controller, to store the selection.
* Add KVO-friendly accessors for that index set.
* Update the index set (using the setter) in the outlineViewSelectionDidChange: delegate method.

James, you've added an instance variable which is simply a copy of other data. This is always a dangerous practice that must be exercised with great care. Although this practice is occasionally necessary for performance reasons, other alternatives should be considered first. In my judgment, getting KVObservability for a variable is not a enough good reason.


For brevity, I didn't tell the whole story. Contrary to what I said in my original post, what I really needed was not all the selected rows, but just the ones at the lowest level of the hierarchy. So in my outlineViewSelectionDidChange: method, I'm not just copying the result of [NSOutlineView selectedRowIndexes], but computing a subset.

But your comments are interesting, thanks.


Maybe you'll be able to get away with it this time, because it's just an index set, but don't make a habit of this. If you ever try this with, for example, Core Data managed objects, you'll be spending some time bug-hunting.

I'm sticking with my method.

-- James W. Walker, Innoventive Software LLC <http://www.frameforge3d.com/> _______________________________________________

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: 
 >binding to number of selected rows in a table (From: James Walker <email@hidden>)
 >Re: binding to number of selected rows in a table (From: Jerry Krinock <email@hidden>)
 >Re: binding to number of selected rows in a table [solved] (From: James Walker <email@hidden>)
 >Re: binding to number of selected rows in a table [solved] (From: Jerry Krinock <email@hidden>)

  • Prev by Date: CrashReporter alternatives for third-party apps?
  • Next by Date: Re: A question about Apple Policy
  • Previous by thread: Re: binding to number of selected rows in a table [solved]
  • Next by thread: Re: binding to number of selected rows in a table
  • Index(es):
    • Date
    • Thread