Question

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];

This still doesn't work and it gives me the warning:

NSScrollview may not respond to '-text'

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

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

Does anyone have any advice on how to get around this?

I am initializing the code the following way:

@interface NetCodeViewController : NSObject {
    IBOutlet NSTextView *codeView;
}
@property(nonatomic, retain) id *codeView;
@end
Was it helpful?

Solution

This:

NSString *medium = codeView.text;

And this:

NSString *medium = [codeView text];

Are actually identical in terms of the generated code (when it works). The difference being that the dot version does additional validation (and then GCC produces an imponderable struct error message anyway).

The real problem is that codeView is declared to be an NSScrollView. You probably want it to be an NSTextView and want to connect it to the NSTextView contained within the scroll view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top