On 27/07/2010, at 5:53 PM, Amy Gibbs wrote:

> If i've got multiple rows selected in a table view, and I want to do 
> something with each of them, do I need some kind of loop in my code, or will 
> cocoa automatically run the code for each selected row? I can't find any kind 
> of while, foreach type of loop example anywhere?


The table's selection is expressed using an NSIndexSet object, retrieved using 
-selectedRowIndexes. You can use its methods such as -firstIndex, 
-nextIndexGreaterThan:, etc to iterate through the index values it contains, or 
use methods on other classes such as NSArray that take an NSIndexSet argument, 
like -objectsAtIndexes:

This latter is probably more common, since having got the subarray of objects 
of interest, you can enumerate those using NSEnumerator or fast enumeration, or 
just use the subarray as an argument elsewhere.

--Graham

 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to