如何修复"属性实现必须在界面' Appdelegate'"

时间:2015-05-02 08:04:32

标签: objective-c appdelegate

//
//  AppDelegate.m
//  Foody
//
//  Created by Iceeiei on 5/2/15.
//  Copyright (c) 2015 pondandfriend. All rights reserved.
//

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

@interface AppDelegate ()



@end
@implementation AppDelegate



@synthesize window = _window;
@synthesize viewController = _viewController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.viewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];

    RecipeList *recipeList = [[RecipeList alloc] initWithNibName:@"RecipeList" bundle:nil];
    self.window.rootViewController = recipeList;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {

}
- (void)applicationWillEnterForeground:(UIApplication *)application {

}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

错误1:

property implementation must have its declaration in interface 'Appdelegate'

错误2:

Property'viewController' not found on object of type 'AppDelegate'

有什么方法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

看起来您没有在.h中为ViewController添加@property表示法。将以下内容添加到AppDelegate.h:

@propery (nonatomic) ViewController *viewController;