Hi Guys, I have a single column table view set up which allows for multiple row selections; then:
on tableView_(sender)
set whichRows to sender's selectedRowIndexes
log whichRows's |class|() -->NSIndexSet
log whichRows --<NSIndexSet: 0x200618dc0>[number of indexes: 3 (in 3 ranges), indexes: (1 3 5)] --ie. I had selected rows 1, 3 and 5
end tableView_
From the console log I see that selectedRowIndexes has returned [number of indexes: 3 (in 3 ranges), indexes: (1 3 5)]
I want to extract “1”, “3”, and “5” - or whatever row numbers are returned.
However, for the life of me, I cannot figure out the correct approach…
Looking at the AppDevDocs, for NSIndexSet, the class of selectedRowIndexes and also “Collections Programming Topics”, I see under NSIndexPath Class reference, the instance method:
"firstIndex
Returns either the first index in the index set or the not-found indicator.
- (NSUInteger)firstIndex
Return Value
First index in the index set or NSNotFound when the index set is empty."
However, whatever incantantion I have tried fails eg:
on tableView_(sender)
set whichRows to sender's selectedRowIndexes
log whichRows's |class|() -->NSIndexSet
log whichRows --<NSIndexSet: 0x200618dc0>[number of indexes: 3 (in 3 ranges), indexes: (1 3 5)] --ie. I had selected rows 1, 3 and 5
set thevalue to current application's NSUInteger's whichRows's firstIndex
log thevalue
(*2012-03-18 22:57:46.628 NewYields[543:903] *** -[NewYieldsAppDelegate tableView:]: Can't get firstIndex of whichRows of NSUInteger. (error -1728) *)
end tableView_
I have tried pretty much every logical variation I could think of from changing the class NSUInteger’s to NSIndexSet’s…(that failed with [<NSIndexSet 0x7fff7124a708> valueForUndefinedKey:]: this class is not key value coding-compliant for the key whichRows… which kind of confuses me in a way.
I feel that I am getting back an array object, fair enough, but it seems a special kind of array…? if I select 4 rows, 3 of them contiguous, i get:
2012-03-18 23:30:33.097 NewYields[603:903] <NSIndexSet: 0x2003f9420>[number of indexes: 4 (in 2 ranges), indexes: (2 4-6)]
ie. I chose rows 2, 4, 5, 6 …getting 4-6 I guess will also ultimately require some further manipulation
Can anybody please offer some help or thoughts on this?