0

I am completely new to this Objective-C programming. I was recently making a very simple app and I couldn't find why the app doesn't work when I am trying to define the UI items in the second controller view. I keep receiving this error message:

"2013-08-04 02:38:45.488 Cheerup[43957:c07] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeMsg.' * First throw call stack: (0x1c91012 0x10cee7e 0x1d19fb1 0xb7ae41 0xafc5f8 0xafc0e7 0xb26b58 0x230019 0x10e2663 0x1c8c45a 0x22eb1c 0xf37e7 0xf3dc8 0xf3ff8 0xf4232 0xffc25 0x2ff3a3 0xfcee3 0xfd167 0xfd1a7 0x4690a2 0x45ab99 0x45ac14 0x10e2705 0x162c0 0x16258 0xd7021 0xd757f 0xd66e8 0x45cef 0x45f02 0x23d4a 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x282d 0x2755) libc++abi.dylib: terminate called throwing an exception (lldb) "

Is there some problems with Appdeligate?

followings are two ViewController of mine:

MenuViewController.h

#import <UIKit/UIKit.h>

@interface MenuViewController : UIViewController{

}

@property IBOutlet UIButton *Botton1;
@property  IBOutlet UIButton *Botton2;

@end

MenuViewController.m

#import "MenuViewController.h"

@interface MenuViewController ()

@end

@implementation MenuViewController

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

AfterMenuViewController.h

#import <UIKit/UIKit.h>


@interface AfterMenuViewController : UIViewController{

    IBOutlet UILabel *WelcomeMsg;
    IBOutlet UIButton *Back;
}


@end

AfterMenuViewController.m

#import "AfterMenuViewController.h"


@interface AfterMenuViewController ()

@end

@implementation AfterMenuViewController

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

Any thoughts? THanks Kamyar

2 Answers 2

1

Your error says welcomeMsg and your code says WelcomeMsg. Naming is case-sensitive. It looks like you may have renamed an outlet after connecting it. Try removing the connection and re-connecting it.

Note that by convention, instance variables and properties start with lower case letters, and class names start with upper case letters. So welcomeMsg is correct.

0

I think there is problem with IBOutlets. Try this

#import <UIKit/UIKit.h>


@interface AfterMenuViewController : UIViewController{

   // comment this
   // IBOutlet UILabel *WelcomeMsg;
   // IBOutlet UIButton *Back;
}

@property (weak, nonatomic) IBOutlet UILabel *WelcomeMsg;
@property (weak, nonatomic) IBOutlet UIButton *Back;

@end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.