NSTextView Help (Sorry in advance)

Hello friends!

It’s been a long time since I’ve been on this forum, and I have missed it dearly. I have recently gotten interested into computer security, and decided to move on from programming to exploitations. But in reality, they definitely share a relationship: hackers are the exact same people as programmers, but with different intentions. Way too many people believe that all hackers are malicious, something I credit to the main-stream media. Long story short, I am trying to build an application, but am having a problem with NSTextView.

This is probably one of the most “noobish” questions, but I have searched and debugged and can’t seem to find a solution to my problem. It seems I have lost my programming edge :P. Here is my script: (I have obviously changed some value names for privacy’s sake)


    on startExecute_(sender)
            debugView's scrollRangeToVisible_({length of theText, 0})
            set targetFile to fileField's stringValue()
            set targetFile2 to file2Field's stringValue() 
            debugView's setString_("Successfully extracted values!")
            do shell script "sleep 1"
        debugView's setString("Testing...")
    end startBinding_

I am getting errors from the debugger as so: (Again, I have taken out the date and project name…)

MyProject[5869:403] -[NSScrollView setString]: unrecognized selector sent to instance 0x7fb35d81e600
MyProject[5869:403] *** -[AppDelegate startExecute:]: -[NSScrollView setString]: unrecognized selector sent to instance 0x7fb35d81e600 (error -10000)

I am sorry in advance for anything I may have looked over, but I would be truly appreciative of anyone who can help me!

Thanks,
TechExpertHD

setString_ should be setStringValue_.

If I remember correctly, setString is right for a text view – the problem is that you’ve connected your outlet, debugView, to the scroll view containing the text view rather than to the text view. That’s what the error message is telling you – -[NSScrollView setString]: unrecognized selector sent to instance 0x7fb35d81e600 Whenever you get an unrecognized selector error, it’s a good idea to check what object the message was sent to, and see if it’s the one you intended. The other really common reason for that error is just misspelled selector name.

Ric

And you do indeed.

Thank you very much Ric! I was suspecting something of the likes, but couldn’t find the NSTextView in Interface Builder. How would I connect it only to the NSTextView but not the the NSScrollView? All I did was ctrl dragged from the AppDelegate to the NSTextView but Interface Builder connected it to: Scroll View - Text View.

Thank you very much!
TechExpertHD

Hello,

Drag the pointer to the upper side of the NSScrollView, IB should detect your NSTextView. It is usually the size of a line in the text view – it does not have the extension of your NSScrollView.

Or you can control-drag to the blue cube of the NSTextView.

Regards,

There shouldn’t be a blue cube for the text view, but you can drag to to where it says text view in the objects list on the left hand side of the main pane in IB. You might have to expand the list to see all the objects, but you can always do all your connections to there if you want (this is one place where objective-c makes things easier, because if your IBOutlet is typed as NSTextView, when you drag over to the scroll view, Xcode knows that you want to connect to the text view not the scroll view).

Ric

Right, Ric, no blue cube but a white small icon with three tiny blue rectangles on it :slight_smile:

Thanks fiz! I have been selecting the whole view than that one “line of text”. Also, thanks to everyone who helped and responded!

Thank you very much!
TechExpertHD