getting value returned from tableView delegate

Hi All,

I have a delegate method for a table view. If I add an array to the array controller for it, rather than a single entry, the method returns either a negative number or a large number sometimes. I am trying to find a way to trap this or check the number (> 0) so the method doesn’t crash. How do I coerce the selectedRow or selectionIndex so I can use it?

 on tableViewSelectionDidChange_(Notification)
      set thistableview to notification's object()
      set indexnum to thistableview's selectedRow() --(this can produce negative numbers)
     --or....
      set indexnum to Backset's selectionIndex()  --(this can produce crazy high numbers)
      set indexnum to indexnum as integer  (or number etc..) (this doesn't throw and error)

       if indexnum < 0 (this throws an exception which can't be caught and crashes)

      --etc etc...

end tableViewSelectionDidChange_()

Thanks, Rob

Hi,

the “crazy high number” is the value for the Foundation enumerated constant NSNotFound, which is in fact the maximum value for an NSInteger.

In case nothing is selected
NSTableView’s selectedRow() returns -1
NSArrayController’s selectionIndex() returns NSNotFound


set indexnum to thistableview's selectedRow()
if (indexnum as integer) = -1 then
	log "nothing selected"
end if