Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kapthehat

macrumors member
Original poster
Jul 1, 2013
51
0
Hello,

I keep getting errors stating that property "SwitchViewController" cannot be found on an object. I attach a copy of the screenshots for both my .h and .m files. Can somebody explain where I am going wrong ? thanks

Kaps
 

Attachments

  • Screen Shot 2013-08-12 at 13.48.20.png
    Screen Shot 2013-08-12 at 13.48.20.png
    523 KB · Views: 163
  • Screen Shot 2013-08-12 at 13.56.34.png
    Screen Shot 2013-08-12 at 13.56.34.png
    394.1 KB · Views: 99
Can you extract the code and post it here instead of the screen shot? (Easier reading, you see. :))

Where is "switchViewController" declared?
 
sure :-

Code:
//
//  BIDAppDelegate.m
//  View Switcher
//
//  Created by Kapil Kapur on 12/08/2013.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import "BIDAppDelegate.h"
#import "BIDSwitchViewController.h"


@implementation BIDAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    self.switchViewController = [[BIDSwitchViewController alloc] initWithNibName:@ "SwitchView" bundle:nil];
    UIView *switchView = self.switchViewController.view;
    CGRect switchViewFrame = switchView.frame;
    switchViewFrame.origin.y += [UIApplication sharedApplication].statusBarFrame.size.height;
    switchView.frame = switchViewFrame;
    self.window.rootViewController = self.switchViewController;
    
    
    [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
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (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

and :-

Code:
//
//  BIDAppDelegate.h
//  View Switcher
//
//  Created by Kapil Kapur on 12/08/2013.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import <UIKit/UIKit.h>
@class BIDSwitchViewController;

@interface BIDAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) BIDSwitchViewController *switchViewController;

@end

thanks

Kaps
 
Code:
//
//  BIDSwitchViewController.h
//  View Switcher
//
//  Created by Kapil Kapur on 12/08/2013.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import <UIKit/UIKit.h>

@class BIDYellowViewController ;
@class BIDBlueViewController;


@interface BIDSwitchViewController : UIViewController

@property (strong,nonatomic) BIDYellowViewController *yellowViewController;
@property (strong,nonatomic) BIDBlueViewController *blueViewController;



@end

and :-

Code:
//
//  BIDSwitchViewController.m
//  View Switcher
//
//  Created by Kapil Kapur on 12/08/2013.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import "BIDSwitchViewController.h"

@interface BIDSwitchViewController ()

@end

@implementation BIDSwitchViewController

- (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
 
Rewrite your applicationDidFinishLaunchingWithOptions method like this and see if this solves it?

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    
    self.switchViewController = [[BIDSwitchViewController alloc]
                                 initWithNibName:@"SwitchView" bundle:nil];
    UIView *switchView = self.switchViewController.view;
    CGRect switchViewFrame = switchView.frame;
    switchViewFrame.origin.y += [UIApplication
                                 sharedApplication].statusBarFrame.size.height;
    switchView.frame = switchViewFrame;
    [self.window addSubview:switchView];

    
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}
 
Thanks. that appears to have fixed it - what did you do ? Also I am trying to connect from the File's owner to the view but dont seem to be able to ?
 
Last edited:
Thanks. that appears to have fixed it - what did you do ? Also I am trying to connect from the File's owner to the view but dont seem to be able to ?

You left out some syntax - including
[self.window addSubview:switchView];


Are you trying to connect the switchView's view to the file's owner?
 
Sorry for the delay. I am unable to see any Received Actions for the File's owner.

----------

resolved.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.