Re: tableview multiple selected loop
Re: tableview multiple selected loop
- Subject: Re: tableview multiple selected loop
- From: Amy Gibbs <email@hidden>
- Date: Tue, 27 Jul 2010 14:10:55 +0100
Thanks,
realised I don't actually need to loop through, as I can just assign
the whole set to the relationship:
[[kit mutableSetValueForKey:@"kitItem"] addObjectsFromArray:kitItems];
Thanks,
On 27 Jul 2010, at 2:05PM, Graham Cox wrote:
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 (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