0

我见过与此类似的其他问题,但无法使用任何解决方案。

。H

@property (assign) IBOutlet NSTextView *commandOutput;

.m

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    Command *aCommand = [[Command alloc] init];
    [self setCommand:aCommand];

    if (self.commandOutput) NSLog(@"textView is not nil");
    [self.commandOutput setString:@""];
}

我得到的错误信息是:-[NSScrollView setString:]: unrecognized selector sent to instance 0x100608630

我还看到:textView is not nil

4

1 回答 1

2

我从错误消息中怀疑是您将commandOutput插座绑定NSScrollViewNSTextView. 如果您使用此日志跟踪,您可以获得更多关于真实类型的信息self.commandOutput

if (self.commandOutput) NSLog(@"textView is not nil: %@", [self.commandOutput description]);

因此,我的建议是检查您在 Interface Builder 中的绑定,并确保您没有无意中将插座拖到错误的视图上。

于 2012-11-16T15:25:54.280 回答