views:

102

answers:

3

In the initial lecture "1. Introduction to Mac OS X, Cocoa touch, Objective-C and Tools" the students are instructed to drag an "Object" into interface builder and set the class actions and outlets. I do not seem to have this ability in my interface builder. Was it removed or disabled in more recent versions?

A: 

No you can still do all those things.

I suggest you read the tutorial from Apple again.

Start with the 'quick' guide and work your way from there.

willcodejavaforfood
+2  A: 

Open a nib file with Interface Builder. One way to do that is to double-click on a file in Xcode in the Resources group with some name ending in '...ViewController.xib' or named 'MainWindow.xib'

In Interface Builder:
Make sure your Library window is open by selecting Menu --> Tools --> Library
Make sure the Objects tab is selected.
On that window's popup menu, go to Library --> Cocoa Touch --> Controllers
You should see a golden translucent cube icon named Object
Drag that icon to your open xib window.

You should now be able to continue along with the Stanford lecture.

Update: Before going into Interface Builder, add your new class to the Xcode project using Menu --> New File --> Cocoa Touch Class --> Objective-C class. Set the Subclass of: popup, then name your class. Add any ivars. Save.

Your class should appear in the class popup in Interface Builder from then on.

Note: There are several ways to add new classes to projects. I am not a fan of the way it's done in the Stanford Lecture.

willc2
This is exactly what I am doing, but when I select that object the "Object Identity" window does not have the same functionality as the one in the tutorial.
Nippysaurus
do a screenshot and I'll compare it to mine.
willc2
I am experiencing the same thing. After inspecting that object and renaming it to MyController, the class outlets subpanes are missing. My screenshot can be found here.. http://www.share-space.com/upload/uploads/missing_outlets.png
phill
I updated the answer to show a common place where you can go wrong.
willc2
When you were referring to "Set the Subclass of: popup.. was that supposed to be an option? I only see nsobject, uiview and UITableViewCell as options.
phill
I meant, set the 'Subclass of:' to one of those three values that you see, whichever is most appropriate. Sorry for not being clearer.
willc2
A: 

Alternate workflow for adding custom classes in Interface Builder.

On the Library pane, select the Objects tab.

At the bottom of the pane, type "NSObject" to filter out all the other class types.

Drag the NSObject icon (a gold cube wireframe) to your ViewController.xib window. Set the View Mode of that window to list mode (the icon with four horizontal lines)

In the Object Identity pane --> Class Identity section --> Class text field, type your new class name. Note how its Name and Type will change in the ViewController.xib window.

Back in the Library pane's filter field, type your new class name to just show that object type.

Select the Outlets tab and add any ivars by clicking the Add button (looks like a plus symbol). Change their names and types from the defaults. Warning: Only object types here, no primitive types. In fact, this feature is half-baked, just add your ivars in Xcode.

Select the Actions tab to add class methods. Change the names from the default values. You can only declare methods that take a single parameter, as far as I can tell.

To turn this Interface Builder class into code that you work with in Xcode, select the Options popup menu (icon looks like a gear).

Choose "Generate Class Files". Save the resulting .m and .h file, with Add to Project set to yes.

You have to go to Xcode and hand-edit the .h file to have the proper superclass. There is commented-out text that tells you what to do.

From there, just add your implementation code to the .m file and you're off to the races. Good luck.

willc2