Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

iPhone 101 guide error

Hello,


I'm following the "Your First iOS Application" (a.k.a. iPhone 101) and under Chapter 5 on page 40 (of the PDF) where it instructs me to create an action for the button in the nib file named "changeGreeting", I'm getting the following error:


Could not insert new action connection: No @implementation found for the class "MyViewController"


I'm not a programming noob, but I'm new to iOS/Mac programming (I've been developing Windows applications for almost 11 years). I followed the guide very carefully up to this point and everything was working until this.


I'm using the latest version of Xcode (4.02).


It seems to be complaining that it isn't aware of MyViewController, but I don't understand why. Any help would be most appreciated. Thanks.

Posted on May 12, 2011 9:32 PM

Reply
25 replies

May 17, 2011 4:50 PM in response to K T

The capitilization problem described in the link above does not appear to be the issue.


Here is the code for MyViewController.h:


#import <UIKit/UIKit.h>



@interface MyViewController : UIViewController {


}


@end




This is the code for MyViewController.m:


#import "MyViewController.h"



@implementation MyViewController


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}


- (void)dealloc

{

[super dealloc];

}


- (void)didReceiveMemoryWarning

{

// Releases the view if it doesn't have a superview.

[super didReceiveMemoryWarning];


// Release any cached data, images, etc that aren't in use.

}


#pragma mark - View lifecycle


- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view from its nib.

}


- (void)viewDidUnload

{

[super viewDidUnload];

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceO rientation

{

// Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationPortrait);

}


@end




As you can see this is nothing but the stock code that comes with first creating the file according to the instructions in the guide. If this is a bug in Xcode 4.02 then it's definitely not ready for primetime. I hope I've done something wrong or there is something missing from the guide. Please help us.

May 17, 2011 5:06 PM in response to QuadraQuack

What's even stranger is that I can manually type in the code that this action was supposed to create for me and THEN if I right-click-n-drag to the declaration in the header file to connect it, it doesn't complain and builds just fine.


(The code is described on pages 40 and 41 of the PDF version of the guide, right after telling you to drag from the button to the header file in assistant view)


Question: Long ago I changed one of the settings for Xcode 3.x to put the brackets on the following line, since that's how I like it stylistically. It's a long shot, but for anyone else having this same error, did you perhaps do the same thing?

Jun 6, 2011 10:01 AM in response to QuadraQuack

Well I'm not sure exactly what caused this, but I can tell you what I did that possibly created the problem. I created a new->file that was a ViewController and made some changes. Then I removed the 3 files that were generated for me because I had just created it to show someone how easy it was to create a UI. The next day I created the ViewController again with the SAME NAME, and the problem we're talking about started happening. Did anyone else do this same thing?


Anyway, I created another new ViewController with a different name, and everything seems to work just fine. So maybe it's an XCode 4.02 bug if you delete then recreate using the same filename? Just a theory.


-Aaron

Jun 26, 2011 12:32 PM in response to QuadraQuack

To everyone experiencing this issue, I wanted to say that I'm pretty sure this is a bug in XCode 4.0.2. What exactly is causing it I don't know, and I hope that Apple is looking into it because it's certainly frustrating. (Not to mention the fact that for newcomers it leaves a bad impression.) All I can say is to type out the code yourself, and it will work, and you can finish the tutorial.


In fact after typing the code out yourself for the first one, the linking method that the tutorial uses appears to work after that. Hopefully Apple will fix this bug soon.

Jul 1, 2011 11:50 AM in response to QuadraQuack

I spent about 20 min debugging this and found that I had an error in the header file that said "incomplete implementation" on my @implementation line. I finally fixed it by moving the bracked on the @intervace line

From:


@interface MyViewController : UIViewController {

}


To:


@interface MyViewController : UIViewController

{

}


It would appear xcode is a bit sensative to bracket placement.

Aug 4, 2011 1:03 PM in response to james957

I did the same thing, added files for "MyViewController", then removed them, then added them again in a different place in the project. Then once I got to the point where I was supposed to add the actions, it gave me this error.


I was able to get it to work properly after I went into both MyViewController.h and MyViewController.m and slightly modified and saved those files. I just added a couple lines of whitespace in both the @interface/@end and @implementation/@end blocks, and then tried to set up the action connection again, and it magically worked.

iPhone 101 guide error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.