Post

Replies

Boosts

Views

Activity

Comment on MacOs - NSTableView, editing single cell
Here is the ViewController code for a test project that demonstrates the issue I'm having with my actual project: (Is there a way to attach the entire Xcode project?) `// //  ViewController.swift //  TEST // //  Created by Phil Bond on 9/13/21. // import Cocoa class ViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource {     var infoForTableView : [String] = ["one", "two", "three", "four", "five"]     override func viewDidLoad() {         super.viewDidLoad()         // Do any additional setup after loading the view.     }     override var representedObject: Any? {         didSet {         // Update the view, if already loaded.         }     }          @IBAction func cellWasEdited(_ sender: NSTextFieldCell) {         print("cell was edited")         print(sender.stringValue)     }           func numberOfRows(in tableView: NSTableView) -> Int {     return infoForTableView.count     }          func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {         return infoForTableView[row]     } } `
Topic: UI Frameworks SubTopic: AppKit Tags:
Sep ’21
Comment on MacOs - NSTableView, editing single cell
@Claud31 thanks. Yes, the delegate (and datasource) have been set for the TableView to my ViewController. I'll add that the tableview is cell based. For my action I've tried NSTextField, NSTextFieldCell and even Any – with no success. My IBAction code (there's nothing in it yet): @IBAction func cellWasEdited(_ sender : NSTextFieldCell) { print("cell was edited") }
Topic: UI Frameworks SubTopic: AppKit Tags:
Sep ’21
Comment on Modifying App Bundle
I must have figured this out about the same time your comment came in. That's exactly what I ended up doing. Thank you!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Comment on MacOs - NSTableView, editing single cell
"Yes, view based is much simpler" Better maybe, but simpler? ;-) In any case, is there a way for the edited cell to trigger an action in the view controller so that I can act on any changes that were made?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
Ah yes... thank you. When I switch the tableview type to view based I can edit the cell but I still want to have that editing trigger an action so that I can act on the changes.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
Here is the ViewController code for a test project that demonstrates the issue I'm having with my actual project: (Is there a way to attach the entire Xcode project?) `// //  ViewController.swift //  TEST // //  Created by Phil Bond on 9/13/21. // import Cocoa class ViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource {     var infoForTableView : [String] = ["one", "two", "three", "four", "five"]     override func viewDidLoad() {         super.viewDidLoad()         // Do any additional setup after loading the view.     }     override var representedObject: Any? {         didSet {         // Update the view, if already loaded.         }     }          @IBAction func cellWasEdited(_ sender: NSTextFieldCell) {         print("cell was edited")         print(sender.stringValue)     }           func numberOfRows(in tableView: NSTableView) -> Int {     return infoForTableView.count     }          func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {         return infoForTableView[row]     } } `
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
I'm using a cell based NSTableView. I tried what you posted but it didn't work – I imagine that's because your example is for a view based TableView?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
@Claud31 thanks. Yes, the delegate (and datasource) have been set for the TableView to my ViewController. I'll add that the tableview is cell based. For my action I've tried NSTextField, NSTextFieldCell and even Any – with no success. My IBAction code (there's nothing in it yet): @IBAction func cellWasEdited(_ sender : NSTextFieldCell) { print("cell was edited") }
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Comment on MacOs - NSTableView, editing single cell
Hi Claude31, Yes, as I said in my post, the tableview appears to function as it should in all other respects.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Sep ’21