Xcode 4和“SIGABRT”错误? (仅适用于iphone) [英] Xcode 4 and "SIGABRT" error? (only for iphone though)

查看:72
本文介绍了Xcode 4和“SIGABRT”错误? (仅适用于iphone)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ios开发和stackoverflow的新手。我确实尝试在发布之前搜索stackoverflow和google。



我构建了一个简单的小应用程序,最初只留下了一个仅限iphone的应用程序,但决定在结束。我愚蠢地说,当我开始了解xcode 4并将其切换到通用然后再返回时,我正在弄乱,所以我不得不重新复制项目并再次执行。这次我用通用应用程序启动它。 (不是当我创建它但是在我去项目并在那里选择它之后)它创建了ipad文件夹和mainwindow-ipad.xib文件但当然是空的,因为我还没有做任何事情。我把它设置为基于标签的应用程序,所以我的iphone版本也有firstview和secondview nib文件,但ipad版本没有。我首先在iphone版本中设置它,它工作正常。然后我去了ipad版本(我确实消除了mainwindow-ipad的第二个标签,因为我不需要它)



然后我去创建一个新的nib文件并将其与main-ipad.h和main-ipad.m一起放在ipad文件夹中。我复制了我的代码并连接了一切,它在ipad模拟器上运行良好,但现在当我尝试运行iphone模拟器时,我得到SIGABRT错误。我拍了一个屏幕截图。我不完全理解objective-c所以我希望有人可以帮助我吗?我可以发布任何代码或任何你需要的东西来帮助我解决这个错误所以请问。



感谢你的任何帮助和建议! / p>

谢谢!



[好吧我会张贴图片但我不能,因为我是新用户,而是我发布突出显示的行和xcode的输出]



错误的文件代码:

  int main(int argc,char * argv [])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain( argc,argv,nil,nil); //错误在这条线上< -----
[池发布];
返回retVal;
}

[OUTPUT]

  2011-06-18 17: 32:43.980价格助手[445:207] ***由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[< UIViewController 0x4e09cc0> setValue:forUndefinedKey:]:此类不是键值最终标签的键值编码。'
***第一次调用堆栈:

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:opt离子:] + 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(UINSBu ndleAdditions)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 CF RunLoopRunSpecific + 208
29 CoreFoundation 0x00d01761 CFRunLoopRunInMode + 97
30 UIKit 0x000177d2 - [UIApplication _run] + 623
31 UIKit 0x00023c93 UIApplicationMain + 1160
32价格助手0x000029a9 main + 121
33价格助手0x00002925开始+ 53

在抛出'NSException'实例后终止

iPhone FirstView nib文件.h代码:

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

iPhone FirstView nib文件.m代码:

  // 
// FirstViewController.m
//价格助手
//
//由Dustin Schreiber于6/15创建/ 11。
//版权所有2011 TheTechSphere.com。版权所有。
//

#importFirstViewController.h


@implementation FirstViewController

/ *
//在加载视图后,通常从nib实现viewDidLoad以进行其他设置。
- (void)viewDidLoad
{
[super viewDidLoad];
}
* /

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//返回YES表示支持的方向
返回(interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning
{
//如果视图没有超视图,则释放视图。
[super didReceiveMemoryWarning];

//释放未使用的任何缓存数据,图像等。
}


- (void)viewDidUnload
{
[percentoffinput release];
percentoffinput = nil;
[discountlabel release];
discountlabel = nil;
[finallabel release];
finallabel = nil;
[super viewDidUnload];

//释放主视图的所有保留子视图。
//例如self.myOutlet = nil;
}


- (无效)dealloc
{
[percentoffinput release];
[discountlabel release];
[finallabel release];
[super dealloc];
}


- (IBAction)计算:(id)发件人{
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 =(合计 - 折扣);
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)发件人{
if([centsinput.text length]> = 2){
if([centsinput] .text length]> 2){
centsinput.text = @;
}其他{
//下一个字段
}
}
}

@end

再次感谢!如果有人对我的代码有任何建议我会爱他们!就像我说的,我是新手,这是我知道的唯一方法。



------------>如果有人想要,我会上传整个项目文件夹。请问。谢谢大家的帮助。我是一个带有xcode的n00b,所以我还没有完全放下它。



项目压缩

解决方案

发布一些使用 finallabel 并尝试调试您的应用程序,以便您可以在应用程序崩溃之前告诉我该行。



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



在XCode中转到Run - > Show - > BreakPoints(或者只是cmd + option + B)。然后双击以添加新符号(符号断点)并键入 malloc_error_break 然后按Enter键。



现在运行您的应用并粘贴控制台文字。



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






检查你的InterfaceBuilder中的连接,你可能用fianllabel错了。
还要检查你的InterfaseBuilder中你的iphone XIB中的自定义类 - >类






UPDATE



转到产品 - >清洁。然后跑。


I'm new to ios development and to stackoverflow. I did try searching both stackoverflow and google before posting.

I built a simple little app, originally just left it an iphone only app, but decided to make it universal in the end. I, stupidly, was messing around when i was getting to know xcode 4 and switched it to universal and then back again so i had to recopy the project and do it again. This time i started it with a universal app. (Not when i created it but after i went to project and selected it there) It created the ipad folder and mainwindow-ipad.xib file but was empty of course since i didn't do anything yet. I had it set up as a tabbed based app so my iphone version had firstview and secondview nib files also, but the ipad version didn't. I set it all up in iphone version first and it worked fine. I then went and laid down the ipad version (i did eliminate the second tab from mainwindow-ipad because i didn't need it)

i then went and created a new nib file and placed it in the ipad folder along with "main-ipad.h" and "main-ipad.m". I copied my code and connected everything and it runs fine on ipad simulator but now when i try and run iphone simulator i get "SIGABRT error. I took a screen shot of it. I don't fully understand objective-c so i was hoping someone can help me? I can post any code or whatever you might need to help me with this error so just ask.

Appreciate any help and suggestions you may have!

Thanks!

[Okay i would have posted image but I can't since I'm a new user, instead i posted the line highlighted and the output from xcode]

Code for file with error:

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 nib file .h code:

@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 nib file .m code:

//
//  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.
// e.g. 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

Thanks again! If anyone has any suggestions for my code i'd love to here them! Like I said, I'm new to it and thats the only way i know to do this.

------------> If anyone wants, I'll upload the entire project folder. Just ask. Thank you guys for all the help. i'm a n00b with xcode so i haven't got it all down yet.

Project Zipped

解决方案

Post some code where you use finallabel and try to debug your app so you can tell me the line just before the app crashes.

Option 2: Try to set a BreakPoint in malloc_error_break so we can have more info about the error.

In XCode go to Run -> Show -> BreakPoints (or just cmd + option + B). Then double click to add a new symbol (symbolic breakpoint) and type in malloc_error_break then press enter.

Now run your app and paste your console text.

UPDATE If you need help http://developer.apple.com/library/mac/#recipes/xcode_help-breakpoint_navigator/articles/adding_a_symbolic_breakpoint.html


Check your connections inside your InterfaceBuilder, you may have it wrong with fianllabel. Also check your Custom Class -> Class in your iphone XIB in your InterfaseBuilder


UPDATE

Go to Product -> Clean. Then Run.

这篇关于Xcode 4和“SIGABRT”错误? (仅适用于iphone)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆