Outlets not recognized.

To the best of my understanding, I’m following the instructions in the tutorials. However, I’m not able to get the Interface Builder to recognize any of my outlets in my ASOC app. I’m sure I’m missing a step, but I can’t figure out what it would be.

First of all, I created a new Cocoa-Applescript Application called TestProject. In this project, I started out with a standard app delegate called TestProjectAppDelegate.applescript. I added a reference to an outlet called aOutlet, and this is what I have so far:

--
--  TestProjectAppDelegate.applescript
--  TestProject
--
--  Created by Hippo Man on 9/18/09.
--  Copyright 2009 __MyCompanyName__. All rights reserved.
--

script TestProjectAppDelegate
	
	property parent : class "NSObject"

	property aOutlet : missing value
	
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		return my NSTerminateNow
	end applicationShouldTerminate_
	
end script

I then opened up MainMenu.xib, and I control-clicked on the blue cube for Test Project App Delegate. All I see is the following

How come I don’t see my aOutlet item?

Thanks in advance for any help you can offer.

Did you save the “TestProjectAppDelegate.applescript” file?

Any outlets you add will not show up in IB until the file is saved.
This is the first thing I do when I don’t see outlets I have set up.

Also, you are missing the opening to.

end applicationWillFinishLaunching_

and change this

return my NSTerminateNow

to

return true

my NSTerminateNow is not working properly. Each time you quit your
app it will log an error to the console and/or not close the app.

I saw Read Class Files on the Interface Builder’s File menu, and so I selected it. It gave me a file chooser dialog, and then I navigated to my TestProjectAppDelegate.applescript file. I selected that file and clicked on Open.

Now, when I control-click on Test Project App Delegate, I have the following:

However, I still don’t see any reference to my aOutlet.

I then tried selecting Reload All Class Files in the Interface Builder’s File menu, but nothing changed.

There must be another step I’m missing … ???

zip it up and email it to craigw@macscripter.net.

Yes. I saved it, but the outlet still doesn’t show up.

That was a slip of the hand when editing my message. The opening “to” is indeed there in my TestProjectAppDelegate file. Here’s the correct code:

--
--  TestProjectAppDelegate.applescript
--  TestProject
--
--  Created by Hippo Man on 9/18/09.
--  Copyright 2009 __MyCompanyName__. All rights reserved.
--

script TestProjectAppDelegate
	
	property parent : class "NSObject"
	
	property aOutlet : missing value
	
	on applicationWillFinishLaunching_(aNotification)
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		return my NSTerminateNow
	end applicationShouldTerminate_

end script

I made this change, but I still have the same problem. There is no reference to my aOutlet in the MainMenu.xib file.

I just sent it. Thank you!

By the way, your SMTP server seems to be doing greylisting, so it might take some time before my message arrives:


When I open the project in IB, right click on the instance of “TestProjectAppDelegate” (blue cube)
this is what I see. Are you not seeing the same thing?

No. I’m not seeing that. There is nothing in the “Outlets” section.

… but I then did another “Reload All Class Files” in IB, followed by “Read Class Files…”. I navigated to TestProjectAppDelegate.applescript and clicked on “Open”. Now, I do see “aOutlet” under the “Outlets” section.

But I did this earlier, and I didn’t see that outlet. Weird.

So now, I created yet another new project called NewTestProject. The AppleScript looks like this, and I definitely, positively did a Save:

--
--  NewTestProjectAppDelegate.applescript
--  NewTestProject
--
--  Created by Hippo Man on 9/19/09.
--  Copyright 2009 __MyCompanyName__. All rights reserved.
--

script NewTestProjectAppDelegate
	
	property parent : class "NSObject"
	
	property aOutlet : missing value
	
	on applicationWillFinishLaunching_(aNotification)
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		return true
	end applicationShouldTerminate_
	
end script

So then I opened MainMenu.xib and control-clicked on the New Test Project App Delegate blue cube, and it looks like this:

And now, I keep trying “Reload All Class Files” and “Read Class Files…” as above, but it isn’t changing.

Even more weird.

PS: It says at the bottom of my posting window that the ‘[ img ]’ tag is “off”, and so I can’t post a nice image like you did. How do I get that tag to be turned on?

OK. I figured it out. When I was doing “Read Class Files…” during my earlier tests, I was accidentally selecting the wrong file to read. I have so many test projects, I confused myself.

But it looks like “Read Class Files…” of the correct file is indeed needed after a Save is done of the App Delegate.

Here are the steps that I have to take:

  1. Create a new Cocoa-AppleScript Application project.

  2. Make sure the App Delegate has the following two lines right before the “on applicationWillFinishLaunching_(aNotification)” line:

   property parent : class "NSObject"
   property aOutlet : missing value

  1. Do a Save.

  2. Open up MainMenu.xib

  3. In the IB File menu, do a “Reload All Class Files”

  4. In the IB File menu, do a “Read Class File…” and select the App Delegate applescript file for this project.

THEN the outlet shows up properly.

I’m not sure about step 5. It might be OK to leave it out. But step 6 is absolutely necessary, at least for me.

You shouldn’t have to do 5 or 6.

One thing that’s easy to do, and gives the symptoms you’re talking about, is to have one project open in Xcode, and another’s .xib open in IB. I’ve done it, and it’s very confusing.

Well, in my case, once I realized that I had issues with looking at the wrong files under IB, I made a point of always doing a Close Document in IB and then completely shutting it down before starting with a brand new Xcode project. And I still have this problem.

Here’s an updated list of steps which reliably reproduce the problem on my 10.6.1 system with versions 3.2 of both Xcode and IB:

  1. Open IB.

  2. Go to IB’s File menu and do a Close Document if it isn’t greyed out.

  3. Go to IB’s FIle menu and do a Close.

  4. Quit from IB.

  5. Open Xcode and create a brand new Cocoa-AppleScript Application project.

  6. Make sure the App Delegate has the following two lines right before the “on applicationWillFinishLaunching_(aNotification)” line:

    property parent : class "NSObject"
    property aOutlet : missing value

The app delegate should now look like this (assuming that the project is named NewTest):

script NewTestAppDelegate
	
	property parent : class "NSObject"
	
	property aOutlet : missing value
	
	on applicationWillFinishLaunching_(aNotification)
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		return true
	end applicationShouldTerminate_
	
end script
  1. Go to Xcode’s File menu and do a Save. Do it again to make double-sure. Do it yet again to make triple-sure.

  2. Open up MainMenu.xib

  3. Control-click on the blue cube for the App Delegate.

In my case, I see the following (could someone tell me how to get the “[ img ] tag: off” setting set to “on” underneath this message posting window?). Note that my aOutlet does not appear:

Only if I perform the following extra step does my aOutlet appear under Outlets:

  1. In the IB File menu, do a “Read Class File…” and select the App Delegate applescript file for this project (in this example, it’s the NewTestAppDelegate.applescript file within the NewTest project’s top-level directory). Then, click on Open.

Without step 10, I have never gotten aOutlet to show up when I control-click on my App Delegate. What am I doing wrong?

That’s odd. One thing to try: instead of double-clicking on MainMenu.xib in Xcode to open it, go into the Finder and double-click on it there. I have had a case where I threw out a project and started a new one with the same name, and the old .xib file was being opened.

Thanks for this suggestion. I followed the steps above with a brand new project name that I never used before. This time, in step 8, I opened up MainMenu.xib by double-clicking on it in the Finder. Unfortunately, this didn’t make a difference. I still had to perform step 10 before I saw aOutlet show up.

So I don’t know what’s causing this to occur for me. However, the “Read Class File…” step seems to take care of the problem, so even if that’s the best I can do for now, at least I have a way to proceed.

Well, I finally fixed this problem, but I’m not sure how.

I shut down Xcode and Interface Builder, and then I deleted all plists, cached objects, and preference files and directories for both of these apps. However, that didn’t fix the problem.

Then, I completely uninstalled Xcode and Interface Builder, and I then deleted all of the items mentioned above and reinstalled Xcode. Again, this didn’t fix the problem.

I then repeated all of the deletes and uninstalls. Then I shut down my machine and restarted, and then I repeated the reinstall of Xcode, and the problem still persisted.

Then I went to bed.

This morning, I redid the previous set of tasks yet again (delete, uninstall, shut down, restart, reinstall), and now, the problem is gone.

So clearly, my computer just wanted me to go away for a while. :slight_smile:

All I can think of is that I must have messed up one or more of the above scenarios multiple times in a row, and that a good night’s sleep made me more attentive to detail so that I finally did it all correctly in the morning. It’s quite unlikely that I screwed it up that many times, but who knows?

In any case, all’s well that ends well. Thanks again for all the help.

Excelsior!