Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access tuples by subscript

Tags:

swift

tuples

Let's say I have this code:

let tuples = ("1", 2, "3", "4", "5", "6", "7", false)

func tableView(tableView:NSTableView, viewForTableColumn tableColumn:NSTableColumn?, row:Int) -> NSView?
{
    let valueForView = tuples[row]
}

Is there any way to access tuples by subscript?

like image 200
BadmintonCat Avatar asked Jun 14 '15 15:06

BadmintonCat


1 Answers

It is kind of possible using reflection:

Mirror(reflecting: tuples).children[AnyIndex(row)].value
like image 187
Thanh Pham Avatar answered Sep 22 '22 07:09

Thanh Pham