Jonnny Jonnny - 1 year ago 211
Swift Question

NSSet has no subscript members

I have a CoreData object that has an relationship that is

. I'm trying to use this as my dataSource, but getting the following

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = playerTableView.dequeueReusableCellWithIdentifier("Cell")! as UITableViewCell
cell.textLabel?.text =[indexPath.row]
return cell

How do I use my NSSet in a tableView and I believe this would be unordered so potentially different each time, so how could I order this set?

Answer Source

You can use allObjects to get an array from the set and sort the objects afterwards.

let orderedPlayers = (game.players!.allObjects as! [Player]).sort { $ < $ }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download