views:

1504

answers:

3

I'm trying to run through the Hello World tutorial for the iPhone and i get this error: Error: expected ';' before 'interface' I have checked and my files are identical (except for whitespace) to the tutorials, and i can't figure out why i'm having this problem. I can provide code if necessary.

HelloWorldAppDelegate.h:

//
//  HelloWorldAppDelegate.h
//  HelloWorld
//
//  Created by RCIX on 7/10/09.
//  Copyright __MyCompanyName__ 2009. All rights reserved.
//

#import <UIKit/UIKit.h>

@class MyViewController

@interface HelloWorldAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MyViewController *myViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) MyViewController *myViewController;

@end

HelloWorldAppDelegate.m:

//
//  HelloWorldAppDelegate.m
//  HelloWorld
//
//  Created by RCIX on 7/10/09.
//  Copyright __MyCompanyName__ 2009. All rights reserved.
//

#import "MyViewController.h"
#import "HelloWorldAppDelegate.h"

@implementation HelloWorldAppDelegate

@synthesize window;
@synthesize myViewController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    MyViewController *aViewController = [[MyViewController alloc]
              initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
    [self setMyViewController:aViewController];
    [aViewController release];
    UIView *controllersView = [myViewController view];
    [window addSubview:controllersView];

    [window makeKeyAndVisible];
}


- (void)dealloc {
    [myViewController release]; 
    [window release];
    [super dealloc];
}


@end

MyViewController.h:

//
//  MyViewController.h
//  HelloWorld
//
//  Created by RCIX on 7/10/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface MyViewController : UIViewController {

}

@end

MyViewController.m:

//
//  MyViewController.m
//  HelloWorld
//
//  Created by RCIX on 7/10/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "MyViewController.h"


@implementation MyViewController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (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.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
A: 

You probably have forgotten a semi-colon after a struct or enum decl or something in the same file or an included file.

kperryua
+4  A: 

Here's your problem, on your first line:

@class MyViewController

Where's the semicolon?

Wade Williams
Nope, that didn't fix it... :(
RCIX
Huh. I must have been in the wrong file... this worked! thanks so much
RCIX
A: 

You don't have this problem, but when I got this error, I had a spare letter at the very beginning of the implementation file of the class that produced the error:

G//
//  ManagedObjectAttributeEditor.m
//  App
//
//  Created by Rose Perrone on 7/28/10.
//  Copyright 2010 Company. All rights reserved.
//

#import "ManagedObjectAttributeEditor.h"

@implementation ManagedObjectAttributeEditor
Rose Perrone