2013-07-10 18 views
0

AppDelegate.h我得到的錯誤物業 '...' 的類型的對象沒有發現 '...'

#import <UIKit/UIKit.h> 

@interface AppDelegate : UIResponder <UIApplicationDelegate> 

@property (strong, nonatomic) UIWindow *window; 

@end 

AppDelegate.m

#import "AppDelegate.h" 

#import "FirstViewController.h" 

#import "SecondViewController.h" 

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:   
goes on like normal app.......... 
@end 

FirstViewController .h

#import <UIKit/UIKit.h> 

@interface FirstViewController : UIViewController 

@property (strong, nonatomic) IBOutlet UIImageView *bGround; 

- (IBAction)settingsPressed:(id)sender; 

- (IBAction)startPressed:(id)sender; 

@end 


@class SecondViewController; 

@interface SecondViewController : UIViewController 


@property(strong,nonatomic)SecondViewController *secondViewController; 

@end 

FirstViewController.m

#import "FirstViewController.h" 

@interface FirstViewController() 

@end 

@implementation FirstViewController 

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

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

- (IBAction)settingsPressed:(id)sender { 

在此行中,它說「屬性‘secondViewController’不是類型的對象FirstViewController「發現它的線下方。

self.secondViewController = 

[[SecondViewController alloc] initWithNibName:@"SecondViewController" 
             bundle:nil]; 

它具有相同的警告,最後在下面的橫線。

[self presentViewController:self.secondViewController animated:YES completion:nil]; 

} 


- (IBAction)startPressed:(id)sender { 
} 
@end 

SecondViewController.h

#import <UIKit/UIKit.h> 

@interface SecondViewController : UIViewController 

@end 

SecondViewController.m

#import "SecondViewController.h" 

@interface SecondViewController() 

@end 

@implementation SecondViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
// Do any additional setup after loading the view. 
} 

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

@end 
+2

您從未將firstViewController聲明爲FirstViewController中的一個屬性。 – atbebtg

+0

這傢伙根本沒有合成屬性secondviewController – Paulo

回答

0

我很困惑,爲什麼你正在申報SecondViewController兩次。您似乎在FirstViewControler.h和它自己的.h文件中都這樣做。無論如何,你的問題似乎是你已經給你SecondViewController你嘗試訪問的屬性。重讀自己的代碼:

@interface SecondViewController : UIViewController 


@property(strong,nonatomic)SecondViewController *secondViewController; 

@end 

你想在FirstViewController.h文件是什麼:

#import <UIKit/UIKit.h> 
#import "SecondViewController.h" 
@interface FirstViewController : UIViewController 

@property (strong, nonatomic) IBOutlet UIImageView *bGround; 
@property(strong,nonatomic)SecondViewController *secondViewController; 

- (IBAction)settingsPressed:(id)sender; 

- (IBAction)startPressed:(id)sender; 

@end 

注意,我導入SecondViewController在.h文件的頂部,內部申報財產它的@interface。

相關問題