Upgraded to xcode 4 could not insert new outlet

Are you following along on Apple’s “Your First iOS Application” guide, found here ?

Did you upgrade to Xcode 4 mid way? Now when you try to create an outlet, and it says it “could not insert new outlet” in scary red letters; something about not know what class you are looking for.

But… my application builds! What the hell?

Confusing, yes, but this worked for me:

1) Go to your helloWorldAppDelegate.m file

2) You’ll see this code:

@synthesize myViewController;

or you might see

1
@synthesize myViewController=_myViewController;

3) If it is like the first example, change it to look like the 2nd one. If it is like the 2nd one, change it to look like the first.

4) Make sure the memory release is correct in your dealloc method at the bottom of the same file. If you changed the @synthesize to look like the 2nd example, make sure the release looks as such:

1
[_myViewController release];

And vice versa.

5) Build, simulate. If it works, try making the connection again from your nib file to your header file. At this point it worked for me.

Oddly enough, once it worked, I was able to reverse the changes in the helloWordAppDelegate.m file without any problems. Clearly this was just a bug in transitioning from Xcode 3 to Xcode 4.

Keep in mind that the two different ways of synthesizing that class variable is simply a matter of stylistic concern. In the earlier pages of the guide, it is explained that the underscore in `_myViewController` is to “remind you that you’re not supposed to access class variables directly “