Xcode 4和“SIGABRT”错误? (只适用于iPhone虽然)

我是新来的ios开发和stackoverflow。 我之前尝试search发布之前,stackoverflow和谷歌。

我build立了一个简单的小应用程序,最初只剩下一个iphone应用程序,但最终决定使它通用。 我愚蠢的是,当我开始了解xcode 4并将其切换到全局然后再回来,所以我不得不重新复制这个项目并重新执行。 这一次我用一个通用的应用程序开始它。 (不是当我创build它,但我去项目后,select它)它创build了ipad文件夹和mainwindow-ipad.xib文件,但当然是空的,因为我什么都没做。 我把它设置为一个基于标签的应用程序,所以我的iphone版本也有第一次查看nib文件,但ipad版本没有。 我把它全部在iphone版本中,它工作正常。 然后我去了,并放下了iPad的版本(我没有消除从mainwindow iPad的第二个标签,因为我不需要它)

然后我去创build一个新的笔尖文件,并将其与“main-ipad.h”和“main-ipad.m”一起放在ipad文件夹中。 我复制我的代码和连接的一切,它在ipad模拟器上运行良好,但现在当我尝试和运行iPhone模拟器我得到“SIGABRT错误,我把它的一个屏幕截图我不完全理解客观C,所以我希望有人可以帮助我吗?我可以发布任何代码或任何你可能需要帮助我这个错误,所以只要问。

感谢您可能有的任何帮助和build议!

谢谢!

[好吧,我会张贴图像,但我不能,因为我是一个新的用户,而是我张贴的行突出显示,从Xcode输出]

代码为错误的文件:

int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); //ERROR IS ON THIS LINE <----- [pool release]; return retVal; } 

[OUTPUT]

 2011-06-18 17:32:43.980 Price Assist[445:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e09cc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key finallabel.' *** Call stack at first throw: ( 0 CoreFoundation 0x00dc35a9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x00f17313 objc_exception_throw + 44 2 CoreFoundation 0x00dc34e1 -[NSException raise] + 17 3 Foundation 0x00795677 _NSSetUsingKeyValueSetter + 135 4 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285 5 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112 6 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239 7 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041 8 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168 9 UIKit 0x000c7628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70 10 UIKit 0x000c5134 -[UIViewController loadView] + 120 11 UIKit 0x000c500e -[UIViewController view] + 56 12 UIKit 0x00038d42 -[UIWindow addRootViewControllerViewIfPossible] + 51 13 Foundation 0x007955e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285 14 UIKit 0x00048ff6 -[UIView(CALayerDelegate) setValue:forKey:] + 173 15 UIKit 0x0021130c -[UIRuntimeOutletConnection connect] + 112 16 CoreFoundation 0x00d398cf -[NSArray makeObjectsPerformSelector:] + 239 17 UIKit 0x0020fd23 -[UINib instantiateWithOwner:options:] + 1041 18 UIKit 0x00211ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168 19 UIKit 0x0001717a -[UIApplication _loadMainNibFile] + 172 20 UIKit 0x00017cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291 21 UIKit 0x00022617 -[UIApplication handleEvent:withNewEvent:] + 1533 22 UIKit 0x0001aabf -[UIApplication sendEvent:] + 71 23 UIKit 0x0001ff2e _UIApplicationHandleEvent + 7576 24 GraphicsServices 0x00ffc992 PurpleEventCallback + 1550 25 CoreFoundation 0x00da4944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 26 CoreFoundation 0x00d04cf7 __CFRunLoopDoSource1 + 215 27 CoreFoundation 0x00d01f83 __CFRunLoopRun + 979 28 CoreFoundation 0x00d01840 CFRunLoopRunSpecific + 208 29 CoreFoundation 0x00d01761 CFRunLoopRunInMode + 97 30 UIKit 0x000177d2 -[UIApplication _run] + 623 31 UIKit 0x00023c93 UIApplicationMain + 1160 32 Price Assist 0x000029a9 main + 121 33 Price Assist 0x00002925 start + 53 ) terminate called after throwing an instance of 'NSException' 

iPhone的FirstView笔尖文件.h代码:

 @interface FirstViewController : UIViewController { IBOutlet UITextField *dollarinput; IBOutlet UITextField *centsinput; IBOutlet UIButton *combinevalue; IBOutlet UITextField *percentoffinput; IBOutlet UILabel *discountlabel; IBOutlet UILabel *finallabel; } - (IBAction)calculate:(id)sender; - (IBAction)backgroundTouched:(id)sender; - (IBAction)autonext:(id)sender; 

iPhone FirstView笔尖文件.m代码:

 // // FirstViewController.m // Price Assist // // Created by Dustin Schreiber on 6/15/11. // Copyright 2011 TheTechSphere.com. All rights reserved. // #import "FirstViewController.h" @implementation FirstViewController /* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } */ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc. that aren't in use. } - (void)viewDidUnload { [percentoffinput release]; percentoffinput = nil; [discountlabel release]; discountlabel = nil; [finallabel release]; finallabel = nil; [super viewDidUnload]; // Release any retained subviews of the main view. // eg self.myOutlet = nil; } - (void)dealloc { [percentoffinput release]; [discountlabel release]; [finallabel release]; [super dealloc]; } - (IBAction)calculate:(id)sender { if ([centsinput.text length] == 0){ centsinput.text = @"00"; } if ([dollarinput.text length] == 0){ dollarinput.text = @"00"; } if ([percentoffinput.text length] == 0){ percentoffinput.text = @"00"; } double cDollars = [dollarinput.text doubleValue]; double cCents = [centsinput.text doubleValue]; double percentoff = [percentoffinput.text doubleValue] / 100; NSString *ccDollars = [[NSNumber numberWithFloat:cDollars] stringValue]; NSString *ccCents = [[NSNumber numberWithFloat:cCents] stringValue]; NSString *placeholder = [NSString stringWithFormat:@"%@.%@", ccDollars, ccCents]; double combined = [placeholder doubleValue]; double discount = combined * percentoff; NSString *discountholder2 =[NSString stringWithFormat:@"%.2f", discount]; discountlabel.text = discountholder2; double newprice = (combined - discount); NSString *str = [NSString stringWithFormat:@"%.2f", newprice]; finallabel.text = str; dollarinput.text = ccDollars; centsinput.text = ccCents; percentoffinput.text = [[NSNumber numberWithFloat:percentoff] stringValue]; } -(IBAction)backgroundTouched:(id)sender { [dollarinput resignFirstResponder]; [centsinput resignFirstResponder]; [percentoffinput resignFirstResponder]; } - (IBAction)autonext:(id)sender { if ([centsinput.text length ] >= 2) { if ([centsinput.text length] > 2) { centsinput.text = @""; } else { //next field } } } @end 

再次感谢! 如果有人有我的代码的任何build议,我很想在这里他们! 就像我说的,我是新手,这是我知道这样做的唯一方法。

————>如果有人想要,我会上传整个项目文件夹。 请问。 谢谢你们的帮助。 我是一个ncode与Xcode,所以我还没有得到它全部。

项目压缩

在你使用finallabel地方发布一些代码,并尝试debugging你的应用程序,以便在应用程序崩溃之前告诉我该行。

选项2:尝试在malloc_error_break中设置BreakPoint,以便我们可以获得有关错误的更多信息。

在XCode去运行 – >显示 – > BreakPoints(或者只是CMD +选项+ B)。 然后双击添加一个新的符号(符号断点)并键入malloc_error_break然后按回车。

现在运行你的应用程序并粘贴你的控制台文本

更新如果您需要帮助http://developer.apple.com/library/mac/#recipes/xcode_help-breakpoint_navigator/articles/adding_a_symbolic_breakpoint.html


检查你的InterfaceBuilder内部的连接,你可能有错误的fianllabel。 另外在你的InterfaseBuilder的iphone XIB中检查你的自定义类 – >类


UPDATE

转到产品 – >清洁。 然后运行。

UIApplicationMain(argc,argv,nil,NSStringFromClass([AppDelegate class])); 只是意味着在程序运行期间抛出exception。 这可能从内存问题到简单的运行时错误。 查看目标debugging器控制台; 它会告诉你错误发生的地方。

打开左上angular的“iOS模拟器”菜单 – >重置内容和设置。 然后退出iOS模拟器和Xcode,然后重新启动计算机。 这将摆脱过程的其他实例。

这个五月份工作对我来说是工作………..

问题在于你的XIB文件。 这个错误通常发生在finalLabel被错误连接或不存在时。 在Interface Builder检查一次连接。

我也有这个错误。 花了这么多时间后,我发现如何解决这个问题。 首先去控制台,看看错误在哪里(我的故事板和它的代码)我纠正我的错误的方式是通过故事板。 在iPhone屏幕下方,会出现一个小小的黄色button。 右键点击它,你会看到这是造成错误。 如果有黄色错误标志,请删除(x)。

如果这不能解决你的错误,那么就尝试制作新的项目,然后用旧项目的旧文件replace它的空白文件。 我从一开始就有同样的错误,通过这个程序运行没有任何错误。

其他人build议重新启动您的笔记本电脑,并再次运行,重新设置iOS模拟器,或更改iOSdebugging器(但是,由于只有一个debugging器,这不适用于最新的x代码)

希望这可以帮助