Indexset

Stupid question…

How do I turn a number into an nsIndexset?

I just want to get the selected row (I can do that) increment it by one and then tell the table to select it…

As far as I can tell my code works until the Use of select row by extending selection…

It is making me weep…

OLIx

Hi,

assuming one row is selected, the function is called once and the table uses an array controller


set selectionIndex to arrayController's selectionIndex()
set indexSet to current application's NSIndexSet's indexSetWithIndexesInRange_({selectionIndex, 2})
arrayController's setSelectionIndexes_(indexSet)

ps.

my current code that doesn’t work to show how dim i am:

set currentLine to aTableView’s selectedRow
set currentLine to currentLine as integer
set currentLine to (currentLine + 1)
set theSet to current application’s NSMutableIndexSet’s alloc()'s init()
theSet’s addIndex_(currentLine)
tell aTableView to selectRowIndexes_byExtendingSelection(theSet, false)

Hi Stefan,

trying your code i get error:

[First_Scoreboard_attemptAppDelegate updateCountry:]: -[__NSArrayM selectionIndex]: unrecognized selector sent to instance 0x400e4ca60 (error -10000)

Arghh

controlling the table view directly try


set selectedRow to tableView's selectedRow()
set indexSet to current application's NSIndexSet's indexSetWithIndex_(selectedRow + 1)
tableView's selectRowIndexes_byExtendingSelection_(indexSet, true)

the error says, the receiver of the selectionIndex: message is an NSArray, not an NSArrayController

It’s sorted Stefan… Thanks s much for your help…

With eurovision tomorrow I need to get this working before our party!

OLIx

I’ll ESCape :wink:

Ps. I quite liked the Swiss song… Was sad it didn’t qualify!