线程 1:由于 XIB 中的未知类而发出信号 SIGABRT

Posted

技术标签:

【中文标题】线程 1:由于 XIB 中的未知类而发出信号 SIGABRT【英文标题】:Thread 1: Signal SIGABRT due to unknown class in XIB 【发布时间】:2012-12-09 17:55:20 【问题描述】:

当我按下链接到该视图的按钮时出现以下错误。为什么?

2012-12-09 18:44:52.634 LNG[42719:c07] Unknown class DensityViewController in Interface Builder file.
2012-12-09 18:44:52.645 LNG[42719:c07] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x71bcb90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ethaneText.'
*** First throw call stack:
(0x1c93012 0x10d0e7e 0x1d1bfb1 0xb7d711 0xafeec8 0xafe9b7 0xb29428 0x2350cc 0x10e4663 0x1c8e45a 0x233bcf 0xf8e37 0xf9418 0xf9648 0xf9882 0x105235 0x3043d2 0x1024f3 0x102777 0x1027b7 0x46dfe2 0x45fad9 0x45fb54 0x10e4705 0x1b920 0x1b8b8 0xdc671 0xdcbcf 0xdbd38 0x4b33f 0x4b552 0x293aa 0x1acf8 0x1beedf9 0x1beead0 0x1c08bf5 0x1c08962 0x1c39bb6 0x1c38f44 0x1c38e1b 0x1bed7e3 0x1bed668 0x1865c 0x2c1d 0x2b45)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

密度视图控制器.h:

#import <UIKit/UIKit.h>
#import "FlipsideViewController.h"
#import "MainViewController.h"
@interface DensityViewController : UIViewController
[More code]

和密度视图控制器.m

#import "DensityViewController.h"

@interface DensityViewController ()

@end

@implementation DensityViewController
[More code]

最后是我的 XIB 的照片(IK 看起来很糟糕,WIP)

我可以做些什么来纠正这个错误? 编辑:完整的.m

#import "DensityViewController.h"

@interface DensityViewController()

@end

@implementation DensityViewController
@synthesize tempratureText, methaneText, ethaneText, propaneText, nbutaneText,     ibutaneText,npetaneText, ipetaneText, nhexaneText, nitrogenText, oxygenText, outputText;

- (void)viewDidLoad

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.


- (void)didReceiveMemoryWarning

[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.


-(IBAction)textFieldReturn:(id)sender

[sender resignFirstResponder];

-(IBAction)backgroundTouched:(id)sender

[tempratureText resignFirstResponder];
[methaneText resignFirstResponder];
[ethaneText resignFirstResponder];
[propaneText resignFirstResponder];
[nbutaneText resignFirstResponder];
[ibutaneText resignFirstResponder];
[npetaneText resignFirstResponder];
[ipetaneText resignFirstResponder];
[nhexaneText resignFirstResponder];
[oxygenText resignFirstResponder];
[nitrogenText resignFirstResponder];



- (void)updateConversionLabel:(UITextField *)textField


NSNumberFormatter *fmt1  =  [NSNumberFormatter new]; //Temp
NSNumberFormatter *fmt2  =  [NSNumberFormatter new]; //Methane
NSNumberFormatter *fmt3  =  [NSNumberFormatter new]; //Ethane
NSNumberFormatter *fmt4  =  [NSNumberFormatter new]; //Propane
NSNumberFormatter *fmt5  =  [NSNumberFormatter new]; //n-butane
NSNumberFormatter *fmt6  =  [NSNumberFormatter new]; //i-butane
NSNumberFormatter *fmt7  =  [NSNumberFormatter new]; //n-petane
NSNumberFormatter *fmt8  =  [NSNumberFormatter new]; //i-petane
NSNumberFormatter *fmt9  =  [NSNumberFormatter new]; //n-hexane
NSNumberFormatter *fmt10 =  [NSNumberFormatter new]; //nitrogen
NSNumberFormatter *fmt11 =  [NSNumberFormatter new]; //oxygen


double temprature = [fmt1  numberFromString:tempratureText.text].doubleValue;
double methane    = [fmt2  numberFromString:methaneText.text   ].doubleValue;
double ethane     = [fmt3  numberFromString:ethaneText.text    ].doubleValue;
double propane    = [fmt4  numberFromString:propaneText.text   ].doubleValue;
double nbutane    = [fmt5  numberFromString:nbutaneText.text   ].doubleValue;
double ibutane    = [fmt6  numberFromString:ibutaneText.text   ].doubleValue;
double npetane    = [fmt7  numberFromString:npetaneText.text   ].doubleValue;
double ipetane    = [fmt8  numberFromString:ipetaneText.text   ].doubleValue;
double nhexane    = [fmt9  numberFromString:nhexaneText.text   ].doubleValue;
double nitrogen   = [fmt10 numberFromString:nitrogenText.text  ].doubleValue;
double oxygen     = [fmt11 numberFromString:oxygenText.text    ].doubleValue;

double Xi = 1;
double Mi = 2;
double Vi = 3;
double Vc = 4;
//Do not mind this, just placeholders for some other stuffs. 

double over1 = Xi * Mi;
double under1 = Xi * Vi - Vc;


double result =  over1 / under1;


NSString *resultString = [[NSString alloc]initWithFormat:@" Test %f", result];
/*
outputText.text = resultString;
*/
if (temprature == 0 || methane == 0 || ethane == 0 || propane == 0 || nbutane == 0 || ibutane == 0 || oxygen == 0 || npetane == 0 || ipetane == 0 || nhexane == 0 || nitrogen == 0)

    outputText.text = @"Please enter all values";
 else

    outputText.text = resultString;



@end

【问题讨论】:

如果您需要答案,您必须改进您的问题。太模糊了 @calvinBhai 怎么样?我得到了几乎所有的代码(我认为是相关的)和截图和错误代码。我还能提出什么? @calvinBhai ???我现在已经尝试了 3 个额外的小时来处理所有可以弄乱的东西,但它似乎仍然对我不起作用。 您确定源文件在您的二进制文件中吗?.. 仅从这些小信息很难判断到底出了什么问题 你能把代码贴在你打电话的地方:setValue:forSomeKey:吗?这就是你的问题所在。具体来说,当您设置 ethaneText 的值时。 【参考方案1】:

尝试删除界面中的 nibe 并重新从头开始。因为您可能会从其他项目中复制 nib,所以有时 xcode 会以这种方式运行。它肯定会起作用。

【讨论】:

以上是关于线程 1:由于 XIB 中的未知类而发出信号 SIGABRT的主要内容,如果未能解决你的问题,请参考以下文章

线程 1:单击按钮时发出 SIGABRT 信号

pyqt4在线程中向主线程中的插槽发出信号

向同一进程中的另一个线程发出信号

从其他线程发出信号

使用 boost 线程:发出信号并等待终止

唤醒线程信号