2009-07-11 11 views
1

我試圖通過iPhone的Hello World教程運行,我得到這個錯誤: 錯誤:預期';' 'interface'之前 我已經檢查過,並且我的文件與教程相同(除了空格),並且我無法弄清楚爲什麼我遇到了這個問題。如有必要,我可以提供代碼。錯誤:預期';'之前在'接口'在Xcode

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 
+1

是的,我會包括代碼 – micmoo 2009-07-11 06:43:26

回答

6

這是你的問題,你的第一個行:

@class MyViewController

哪裏分號?

+0

不,它沒有解決它... :( – RCIX 2009-07-11 07:07:07

+0

嗯,我一定是在錯誤的文件...這工作!非常感謝 – RCIX 2009-07-11 07:52:39

0

您可能在同一個文件或包含文件中的struct或enum decl之後忘記了一個分號。

6

你沒有這個問題,但是當我得到這個錯誤,我在類的實現文件的最開始備用信所產生的錯誤:

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

#import "ManagedObjectAttributeEditor.h" 

@implementation ManagedObjectAttributeEditor 
相關問題