So I was having a lot of trouble last night with this project, which felt odd since most of the iOS UIKit projects were fairly straightforward and this project came straight from that set. I managed to get it so that the interface (at least as shown in IB) was looking the same, and the print call I placed into SourceViewController.numberOfRows(in:)
was firing off, but tableView(viewFor:row:)
was never being called.
Compared against the project file in Git and the only changes I was seeing (outside of Main.storyboard having a ton of extra lines on my side) were in comments and whitespace.
Decided to poke around a bit using Debug > Capture View Hierarchy and compared with the version from Git (which was working properly) and it turned out that the NSScrollview
was far smaller than it should be, and with a Y position way off the mark (Git version's scroll view was (x: 0, y: 0, width: 250, height: 300)
, mine was (x: 0, y: 298, width: 17, height: 2)
). Great, now we've got something to go off of.
Checked the NSScrollView
size inspector in IB, everything in that panel (and the rest of the inspector panels) matched the other project until I got to looking at the constraints and saw that my view only had 2 constraints, while the one from Git had 4. Turns out when hitting "Reset Constraints" on it when the book said to do so ended up only adding the top and leading constraints, but not the bottom and trailing constraints, causing the view to collapse (though admittedly, I'm still not quite sure why).
In either case, just wanted to throw this out there as a note to help anyone else who runs up against the same issue. It also doubles as a friendly reminder of how useful the Capture View Hierarchy debugging tool is.
Looking forward to moving on to the next project!