I am following a personal learning path for macOS development, learning the basics of C and Objective-C before moving on to Swift (which I already know a bit, but felt the need to learn where all that came from). I am aware there are better, more modern and functional APIs, so please do not suggest learning that or SwiftUI. The point of this question is knowing what is not working in my example.
I closely followed this tutorial, whose source code can be downloaded from here. My code is available here, instead.
The first thing I noticed while following the tutorial is that Xcode (v 13.3.1 on macOS
12.3.1) doesn't add a Collection View Item and a View to the xib's workbench when dragging out a Collection View from the Object Library to the main window. I worked around it by manually adding a Collection View Item and a Custom View to design the UI as the tutorial showed. I triple-checked and connected all outlets as instructed then pressed Cmd-R to build and run. The app crashed, bringing me to main.m
at the return NSApplicationMain(argc, argv);
line with the following error:
I understand part of this error, but do not know how to "register one item nib or class", while dataSource is not covered in this tutorial.
Comparing with the source code I noticed that an extra outlet was added from the Collection View, connecting its itemPrototype
to the CollectionViewItem
. I did just that and, this time, Xcode refused to build throwing this error:
Do you know how to make this work? I would also appreciate any and every explanation on the first error.
Thank you for your patience and help.
NSOutlineView
changed quite a bit in macOS 10.11 and isn't compatible with the tutorial. NSOutlineView
can be used in legacy mode by choosing layout Content Array (Legacy)
in IB.