代码之家  ›  专栏  ›  技术社区  ›  thyrgle

nsscrollview可能不响应“-text”

  •  0
  • thyrgle  · 技术社区  · 15 年前

    I am having trouble assigning a NSString to the text of a NSScrollView. I have tried the following:

        NSString *medium = codeView.text;
    

    That didn't work so then I tried:

        NSString *medium = [codeView text];
    

    这仍然不起作用,它给了我警告:

    nsscrollview可能没有响应 “文本”

    Or in the case of the "." operator it gives me the error:

    Request for member 'text' is something not a structure or union.

    有人对如何解决这个问题有什么建议吗?

    我按照以下方式初始化代码:

    @interface NetCodeViewController : NSObject {
        IBOutlet NSTextView *codeView;
    }
    @property(nonatomic, retain) id *codeView;
    @end
    
    1 回复  |  直到 15 年前
        1
  •  2
  •   bbum    15 年前

    这是:

    NSString *medium = codeView.text;
    

    而这:

    NSString *medium = [codeView text];
    

    The real problem is that codeView is declared to be an NSScrollView . 你可能希望它是一个 NSTextView 想把它连接到 NSTEXVIEW 包含在滚动视图中。