Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to convert an IndexSet to an int array?

Tags:

swift

I want to convert NStableView.selectedRowIndexes to an int array. Is there a fast way to do that? Or should I iterate the IndexSet and push each item to an array?

like image 917
vincentf Avatar asked Jan 31 '18 04:01

vincentf


1 Answers

There are two simple ways you can do it.

1) Use map

let indexes = tableView.selectedRowIndexes.map({$0})

2) Pass the NSIndexSet into the Array initialiser

let indexes = Array(tableView.selectedRowIndexes)

like image 199
Samah Avatar answered Nov 18 '22 13:11

Samah