1

ビルド時に 2 つのエラーが発生します。これらは AppDelegatem ファイルにあります。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

2 つのエラーがある行:

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

エラー 1:

Receiver type "ViewController" for instance messages is a forward declaration

エラー 2:

Receiver "ViewController" for class messages is a forward declaration

警告のある行:

self.window.rootViewController = self.viewController;

アラート:

Incompatible pointer types assigning to 'UIViewController *' from 'ViewController*'

必要に応じて、ViewControllerm ViewControllerh AppDelegatem のテキスト ファイルをここで見つけることができますhttp://ninjabreakbot.com/stack/

プロジェクトはiOS5用です。私はこれに非常に慣れていません。このような質問に役立つものを教えてください。または、十分に提供されている場合は、ソリューションをご利用ください。

ありがとう!

4

2 に答える 2

5

エラーメッセージ:instance messages is a forward declaration通常、コンパイラがクラスの宣言について認識していないことを意味します。つまり、適切なヘッダーが含まれていません。

あなたの場合#import <ViewController.h>、 AppDelegate.m の先頭に書き込むと、このコンパイラの問題に対処する必要があります。

于 2012-04-13T04:23:50.437 に答える
2

確認してくださいinitWithNibName。nibファイル名ViewControllerですか、それとも別の名前ですか?

書き込み#import "ViewController.h"@property (strong, nonatomic) ViewController *viewController;AppDelegate.h ファイルに

AppDelegate.m@synthesize viewController ;ファイルに書き込む

.h ファイル ::

#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;

@end

.m ファイル::

#import "AppDelegate.h"
#import "ViewController.h"

@implementation AppDelegate

@synthesize window;
@synthesize viewController ;



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}
@end
于 2012-04-13T04:58:42.480 に答える