small medium large xlarge

18 Jun 2011, 23:30
Mark (2 posts)

Hi guys,

Ive been working through chapter 4 and I cannot get my IBOutlet to connect to the NSTextview window. No matter where i drag the blue connecting line to from outlet (even the very top as described in the xcode 4 appendix pdf) it will not highlight and connect.

When i select the actual text window the class name is displayed as NSScrollview, ive tried changing this to NSTextview but it just defaults back.

If I change my .h file to:

@interface NotifyingClass : NSObject { IBOutlet NSScrollView *textView; } - (IBAction)displaySomeText:(id)sender; @end

Then the outlet will allow me to connect to the text window as the whole thing highlights blue the moment you point the blue line at it.

However after build when I press the button in this view however no text is returned in the Text window.

Any ideas whats going on here? Ive checked the code a number of times and theres no typo’s that I can see. How can i get the inspector to see my inserted text view as NSTextView instead of NSScrollView so it will connect?

Ive been on this all day and now Im well and truly stumped :/

Many thanks Mark.

19 Jun 2011, 10:37
Tim Isted (105 posts)

Hi Mark,

A few things to check:

a) when you dragged out the text view, did you definitely drag out a text view and not just a plain scroll view, or perhaps a table view? The text view icon looks like this in the Object Library:

b) if you just select a text view object with a single click, you will only select the outermost object, which in this case will be the containing scroll view. The text view is contained (visually) within a scroll view object. To check this object hierarchy in Xcode 4’s Interface Builder, click the little right-pointing arrow box at the bottom of the Interface Builder left list of icons:

(Alternatively, choose Editor > Show Document Structure Area)

The left list will change to show an outline list with little expansion triangles. If you expand them all, the text-view related portion will show up like this:

If correctly set, you should see the enclosing scroll view holding a text view and two scroller objects.

(If you’re wondering where the extra view containing the Scroll View comes from, it’s because any NSWindow has a content view, which is the actual view that contains everything in the main area of the window.)

c) Note that the “text” and “view” are two different words so check the spelling of NSTextView with a capital V; you should get a compiler error if this is incorrect, though.

Please let me know how you get on. Tim

19 Jun 2011, 12:00
Mark (2 posts)

Hi Tim, thankyou for the quick and very detailed response :)

The Object is indeed the correct text view, I checked the heirachy in the editor builder by clicking on the little right arrow and opened up the view and it appeared exactly as on your picture above. I selected the Text View and that changed the custom class to NSTextView.

I still couldn’t get the outlet blue line to connect to the Text View within the graphical window, however if I right click notifying class in the heirachy view and then connect the blue line to the “Text View” line within the same objects heirachy, That does connect and on build the program now displays the text called in the text view window!

Thanks again for the help, I think its great that you are doing the Xcode 4 updates, I bought the book with the intention of using 3.2 but saw 4 was now available and thought “may as well get used to it now” ;)

Now my TextApp is running properly i’m looking forward to getting into chapter 5.

Many thanks Mark.