SIGABRT-此类不是密钥的密钥值编码兼容

时间:2013-08-04 09:59:45

标签: objective-c sigabrt

我对这个Objective-C编程完全陌生。我最近制作了一个非常简单的应用程序,当我尝试在第二个控制器视图中定义UI项目时,我找不到为什么应用程序不起作用。我一直收到此错误消息:

“2013-08-04 02:38:45.488 Cheerup [43957:c07] *由于未捕获的异常'NSUnknownKeyException'终止app,原因:'[setValue:forUndefinedKey:]:此类不是键值符合编码的关键welcomeMsg。' * 第一次抛出调用堆栈: (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调用抛出异常 (lldb)“

Appdeligate有问题吗?

以下是我的两个ViewController:

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

有什么想法? 谢谢 Kamyar

2 个答案:

答案 0 :(得分:1)

您的错误显示为welcomeMsg,而您的代码显示为WelcomeMsg。命名区分大小写。您可能在连接后重命名了插座。尝试删除连接并重新连接。

请注意,按照惯例,实例变量和属性以小写字母开头,类名以大写字母开头。所以welcomeMsg是正确的。

答案 1 :(得分:0)

我认为IBOutlets存在问题。试试这个

#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