Hello Everybody,
I have written a script in swift using a NSMutableArray (containing strings).
I want to put the result inside a NSMutableDictonnary so I could edit it in NSTableView (containing two columns, one with strings, the other one with checkboxes) and collect information about the checkboxes status. Everything goes fine except when I try to convert the NSMutableArray to NSMutableDictonnary.
I don't find the API and the syntax to do that.
Could anyone help me?
var array : NSMutableArray! = NSMutableArray()
var dataArray:[NSMutableDictionary] = [["firstName": "", "fullTimeEmp": 0]];
...
contenu = ctlelems[elem] as! String
array.addObject("\(contenu)")
func numberOfRowsInTableView(aTableView: NSTableView) -> Int
{
let numberOfRows:Int = array.count
println(numberOfRows)
return numberOfRows
}
func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, row: Int) -> AnyObject?
{
let object = array[row] as! NSMutableDictionary
if ((tableColumn!.identifier) == "fullTimeEmp")
{
return object[tableColumn!.identifier] as? Int!
}
else
{
return object[tableColumn!.identifier] as? String!
}
}
func tableView(tableView: NSTableView, setObjectValue object: AnyObject?, forTableColumn tableColumn: NSTableColumn?, row: Int)
{
dataArray[row].setObject(object!, forKey: (tableColumn?.identifier)!)
}