简体   繁体   中英

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:

在此处输入图片说明

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). 在此处输入图片说明

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

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: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM