0
votes

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 {

On this line it says "Property 'secondViewController' not found on object of type 'FirstViewController' It's the line directly below.

self.secondViewController =

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

It has the same warning as the last on the line below.

[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
1
You never declared secondViewController as a property in your FirstViewController.atbebtg
The guy simply did not synthesise the property secondviewControllerPaulo

1 Answers

0
votes

I'm confused as to why you are declaring SecondViewController twice. You seem to do so both in FirstViewControler.h and in its own .h file. Regardless, your issue seems to be that you have given SecondViewController the property which you are trying to access. Reread your own code:

@interface SecondViewController : UIViewController


@property(strong,nonatomic)SecondViewController *secondViewController;

@end

What you want in your FirstViewController.h file is this:

#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

Note that I import SecondViewController at the top of the .h file, and declare the property inside its @interface.