Property not found on object

Discussion in 'iOS Programming' started by Kapthehat, Aug 12, 2013.

  1. Kapthehat macrumors member

    Joined:
    Jul 1, 2013
    #1
    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
     

    Attached Files:

  2. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #2
    Can you extract the code and post it here instead of the screen shot? (Easier reading, you see. :))

    Where is "switchViewController" declared?
     
  3. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #3
    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
     
  4. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #4
    Edit: Ignore this post - I see it now. Let me look over the code / screen shot and will come back to you
     
  5. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #5
    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
    
    
     
  6. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #6
    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;
    }
    
     
  7. Kapthehat, Aug 12, 2013
    Last edited: Aug 12, 2013

    Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #7
    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 ?
     
  8. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #8
    You left out some syntax - including
    [self.window addSubview:switchView];


    Are you trying to connect the switchView's view to the file's owner?
     
  9. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #9
    Sorry for the delay. I am unable to see any Received Actions for the File's owner.

    ----------

    resolved.
     
  10. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  11. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
  12. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #12
    Then, as a courtesy, please set the Resolved prefix on this thread. Thank you.
     

Share This Page