Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift & NSTableView - Simply select a row

I'd like to programatically select a row in my NSTableView, with just one column.

func selectColumnIndexes(_ indexes: NSIndexSet!,
    byExtendingSelection extend: Bool)

I have been playing around with this, but I am not sure how to write "Select row #2".
Do I have to start with the variable connected to the @IBOutlet of my Table View? I have to indicate it is about my NSTableView somehow.

Thanks!

like image 676
Isaiah Avatar asked Aug 12 '14 19:08

Isaiah


People also ask

What is SWIFT stands for?

SWIFT is an acronym for the Society for Worldwide Interbank Financial Telecommunications and may also be referred to as a CIC code.

Which country owns SWIFT?

How is SWIFT governed? SWIFT is a cooperative company under Belgian law and is owned and controlled by its shareholders (financial institutions) representing approximately 2,400 Shareholders from across the world.

What countries are in SWIFT?

It is based in Belgium and is governed by the central banks of eleven industrial countries, including Canada, France, Germany, Italy, Japan, the Netherlands, Sweden, Switzerland, the United Kingdom, and the United States, in addition to Belgium.

What does SWIFT actually do?

The SWIFT payment network allows individuals and businesses to accept/send international money via electronic or credit card payments. This can be done even if the customer or vendor uses a different bank than the payee. The network is a place for secure financial messaging.


2 Answers

@Isaiah answer in Swift 3.0:

.selectRowIndexes(NSIndexSet(index: 0) as IndexSet, byExtendingSelection: false)
like image 92
curt Avatar answered Oct 03 '22 23:10

curt


Okay, I've got it. It turned out to be

@IBOutlet weak var NoteTableView: NSTableView!
NoteTableView.selectRowIndexes(NSIndexSet(index: 0), byExtendingSelection: false)

I couldn't quite figure out the part with NSIndexSet. I was fiddling around with init(), which turned out to be unnecessary.

like image 24
Isaiah Avatar answered Oct 03 '22 21:10

Isaiah