TAGS :Viewed: 4 - Published at: a few seconds ago

secondViewController.h :

#import <UIKit/UIKit.h>

@interface secondViewController : UIViewController

@end

viewController.m :

#import "ViewController.h"
#import "secondViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize secondViewController;

- (IBAction)switchView:(id)sender{
    [self.view addSubview:secondViewController.view atIndex:0];
}

property view not found no object of type secondViewController what's the trouble?

Answer 1


-(IBAction)switchView:(id)sender{
secondViewController *second = [[secondViewController alloc] init];
[self.view addSubview:second.view atIndex:0];
}

Also, delete that @synthesize secondViewController;.