2 Replies Latest reply: Apr 11, 2010 5:28 AM by mikkeljuhl
mikkeljuhl Level 1 (0 points)
Hi..

New in here.. I need some help, to be honest.. I just started out with the "Your First iPhone OS Application."

I get the error "no declaration of property 'MyViewController' found in the interface," in my "Hello_WorldAppDelegate.m" (here the error is in @synthesize)

My: Hello_WorldAppDelegate.h is as following:

#import <UIKit/UIKit.h>

@class MyViewController;
@interface Hello_WorldAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MyViewController *myViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;


@property (nonatomic, retain) MyViewController *myViewController;

@end

Which I think is where my 'interface' should be.

And my Hello_WorldAppDelegate.m is as following:

#import "MyViewController.h"
#import "Hello_WorldAppDelegate.h"

@implementation Hello_WorldAppDelegate



@synthesize window;
@synthesize MyViewController; //This is where the error pops up.. no declaration of property 'MyViewController' found in the interface


- (void)applicationDidFinishLaunching:(UIApplication *)application {

MyViewController *aViewController = [[myViewController alloc]
initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
[self setMyViewController:aViewController];
[aViewController release];

UIView *controllersView = [myViewController view];
[window addSubview:[myViewController view]];

// Override point for customization after application launch
[window makeKeyAndVisible];
}


- (void)dealloc {
[myViewController release];
[window release];

[super dealloc];
}


@end

Can you guys help me out? Thank you so much!

iPhone, iPhone OS 3.1.3
  • RayNewbie Level 5 (6,810 points)
    Hi Mikk, and welcome to the Dev Forum!
    mikkeljuhl wrote:
    I get the error "no declaration of property 'MyViewController'

    It looks like you just need to change the case of 'M' in a couple places:

    @synthesize myViewController; // <-- lower case 'm' for instance variable

    (void)applicationDidFinishLaunching:(UIApplication *)application {
    MyViewController *aViewController =
    [[MyViewController alloc] // <-- upper case 'M' for the class

    initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle];
    [self setMyViewController:aViewController];
    [aViewController release];
    // ...
    }

    The second error should show up as soon as you fix the first.
    - Ray
  • mikkeljuhl Level 1 (0 points)
    Thank you so much man! Much appreciated!