Search code examples
swiftmacosuistoryboardiboutletcustom-view

How to add IBOutlet of a NSTextField in a custom View correctly in macOS?


I try to create an outlet from a NSTextView, which is a subview of my NSView derived custom class called GeneralView. I want to connect this outlet to my GeneralView class but Xcode doesn't like it. I get the following screen:

enter image description here

In this image, I want to connect an @IBOutlet from the NSTextField that contains '0000' to 'tfLiid' in GeneralView.

It only works if I create a @IBOutlet to the ViewController. But I have like more than 50 views (textfields, progress bars, checkboxes and so on...) I need to update, so I want to split those views in 3 parent views and keep the ViewController clean by holding only the 3 parent (or group) views.

The image below makes you understand more of what I tried to achieve (I hope). enter image description here

I just don't know how to get this done right in Xcode, it's not a programming problem. Thank you.


Solution

  • I found a solution, just by experimenting trying out. I just couldn't let it go. Anyway, you have to drag from the little @IBOutlet circle (on the line number) to the view you want to connect it to. I don't know why the other way around doesn't work, there must be a reason for it.

    An image below for a visual example: enter image description here