简体   繁体   中英

How to connect an IBOutlet to an NSTextView

Unlearned programmer here. Last time I used a NSTextView I was able to do it by adding a class to my xib file with all my outlets declared as such:

@interface Fusebox : NSObject
{
   IBOutlet id object1;
   IBOutlet id object2;
   ....
}

Now I am trying to code my interface properly, using the application delegate because Xcode 5 does adding a separate class file differently, if at all. I attempted to have Xcode's IB create the property of a NSTextView. But it wont creates this:

@property (weak) IBOutlet NSScrollView *results;

instead of what I need, which I think is this:

@property (weak) IBOutlet NSTextView *results;

An NSScrollView is completely useless for my purposes of outputting formatted (mainly line breaks) strings. When i try to hand code it as a NSTextView, it wont let me connect the outlet, only bind it. I am grabbing on a text view object from the library in the interface builder, so what am i doing wrong?

I think you aren't actually hitting the NSTextView - by default, it's imbedded in an NSScrollView. Xcode probably thinks you're trying to connect the outlet to the scrollview.

Try expanding the left pane of Interface Builder and connect the outlet to the sidebar:

在此处输入图片说明

Right-click-dragging from that highlighted row above to the code gives the expected result:

在此处输入图片说明

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