I have an array called teamArray which contain a teamObject with a id, name and shortname. these names is looped into and populated in an tableView. All these cells can be selected and when a cell is selected the indexPath is inserted into a cellSelected array. I would like to save the selected cells id's from the teamArray into a new array. So I guess I need to compare the cellSelected arrays indexPath with the teamArray? How can I do this?
arrays
var teamArray = Array<Team>()
var cellSelected = NSMutableArray()
didSelectRowAtIndexPath
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
if (self.cellSelected.containsObject(indexPath)) {
self.cellSelected.removeObject(indexPath)
} else {
self.cellSelected.addObject(indexPath)
}
tableView.reloadData()
}
teamObject
class Team: NSObject{
var id: Int!
var name: NSString!
var shortname: NSString!
init(id: Int, name:NSString, shortname: NSString) {
self.id = id
self.name = name
self.shortname = shortname
}
}