Hi,
I am interested in the original (Objective C) tutorial.
However, I cannot get to it. The āoriginalā link points back to your new (Swift)
tutorial. I tried to get the original tutorial from the āTutorial Archivesā,
but it has the same problem. It points to your tutorial. (it is like Catch XXII symptom)
Could you please let me know how to get to the original tutorial?
Thank you
Hynek
Hi,
thanks for your reply. One suggestion for updates - it might be good to contain info āfromā (what was the original) and ātoā (what is now new tutorial). In such case, if the link to original does not work, the info will be sufficient to get the information about the original.
Thanks
Hynek
Thank you for the fantastic tutorial. Iām new to all this, so it is nice to get such good explanations (and also using Swift since so much of Appleās documents are still in Obj-C).
I do have one question that I havenāt been able to figure out. Is there a way to make one of the columns in a TableView an input column? Iām thinking of an App that works a bit like an Excel Spreadsheet. I want one column that has the data entry and then two more columns that do the calculations based on the current data and row above it. I havenāt found how to create a column of input data though.
Iāve been trying this, Warren, making a field editable, and itās not working I think because the tableview is set to View based. Changing it to Cell Based kicks out all the Table Cell Views and breaks everything. I donāt suppose there are any other thoughts on how to catch changes to editable cells?
Essentially - kick the cells textfield into Editable mode in IB and then send its action to the view controller to update your datasource. You can get the row/column information by asking the tableviewā¦
@IBAction func endEditing(_ sender: Any) {
if let textField = sender as? NSTextField {
let row = tableView.row(for: textField )
let column = tableView.column(for: textField)
print ("edit row \(row) - column \(column) -> \(textField.stringValue)")
}
}
One last question; Iād quite like to put, say, a MASSHortcutView (derived from a Custom View) and maybe a button into cells. Iāve tried but nothing shows. Can it be done?
I didnt have any issues dragging an NSView into NSTableCellView and constraining it there but maybe you need to leverage the func register(NSNib?, forIdentifier: String) API here.
Construct your view hierarchy in a XIB which has a NSTableCellView as its top level object and then register that NIB before you use it.
Now it works. I must have been doing something wrong before. I didnāt need the nib. Just set the Custom View class to MASShortcutView and it was fine. It might be different for the button, though but I can figure that out now.
thanks again.
Selecting a directory when running this code without any changes gives me the following messages among others prior to it. Iām running Sierra 10.12.3 and Xcode Version 8.2.1 (8C1002) using Swift 3.
2017-03-11 10:52:11.044337 FileViewer[16156:845670] [Layout] Detected missing constraints for <NSVibrantSplitDividerView: 0x600000185620>. It cannot be placed because there are not enough constraints to fully define the size and origin. Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once.
ā¦
error: Error Domain=BRCloudDocsErrorDomain Code=12 āApp library not found: ācom.apple.Documentsāā UserInfo={NSDescription=App library not found: ācom.apple.Documentsā}
Represented object: file:///Users/michaeltoth/Documents/quiet-sky-7167/spec/
Hi, first, thanks for all the great tutorials! I was wondering if you can point out how changing the font color of a selected TableRowView can be achieved manually.
For example when I define a different font color for the first row and a different one for all the following ones in func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { it will overwrite the font color but still thereās no way to change it for selected ones. Also it overwrites the common color change for selected rows. Any idea?
As you can see from the name, Iāv mainly been in iOS, but Iām working on a complimentary app in macOS.
Always fun to learn something new.
However, Iāve run into a bit of bother.
I have, in the iOS app a table cell that I need to duplicate in the macOS app.
It looks like this, where I have several labels, image and some coloured dots.
Is this possible to create in macOS? Is there a tutorial somewhere that show how something like this can be achieved?
Modern macOS table cells are NSViews that you recycle so you can do anything you care to construct in IB or programmatically
The important API youāll want to use on NSTableView here are func register(NSNib?, forIdentifier: String) to set your cell up via IB func make(withIdentifier identifier: String, owner: Any?) -> NSView? to get new or recycled instance (like dequeue)
And on the delegateā¦ func tableView(NSTableView, viewFor: NSTableColumn?, row: Int)
NSTableView has much the same API as UITableView so all the stuff like setting heights is the same. I dont think its gotten automatic cell heights yet.
Best docs here are the apple docs Apple Developer Documentation which explain a lot about views and using them in tables