目标C,线程1程序接收信号SIGABRT [英] Objective C, Thread 1 Program Received Signal SIGABRT

查看:102
本文介绍了目标C,线程1程序接收信号SIGABRT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Interface Builder编译和运行Objective C应用程序的简单教程。我正在使用Xcode 4.0.2并在iOS(iPhone)上进行模拟4.3

I am trying to compile and run a simple tutorial for an Objective C app using Interface Builder. I am using Xcode 4.0.2 and simulating on iOS (iPhone) 4.3

http://www.switchonthecode.com/tutorials/creating-your-first-iphone-application-with-interface-builder

当我构建项目时,它构建正常但是一旦应用程序尝试运行它就崩溃了:

When I build the project, it builds alright but once the app tries to run it crashes with:

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"SimpleUIAppDelegate");
    [pool release];
    return retVal;
}

我在第4行得到错误:int retVal = UI ... Thread 1:程序接收信号SIGABRT。

I get the error on line 4: int retVal = UI... Thread 1: Program Received Signal "SIGABRT".

如果为了清楚起见需要发布该项目的其他文件,我可以这样做。

If the other files of this project need to be posted for clarity, I can do that.

谢谢!

编辑:

SimpleUIViewController.h:

SimpleUIViewController.h:

#import <UIKit/UIKit.h>

@interface SimpleUIViewController : UIViewController <UITextFieldDelegate> {
    UITextField *textInput;
    UILabel *label;
    NSString *name;
}

@property (nonatomic, retain) IBOutlet UITextField *textInput;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, copy) NSString *name;

- (IBAction)changeGreeting:(id)sender;

@end

SimpleUIViewController.m:

SimpleUIViewController.m:

#import "SimpleUIViewController.h"

@implementation SimpleUIViewController

@synthesize textInput;
@synthesize label;
@synthesize name;

- (IBAction)changeGreeting:(id)sender {
    self.name = textInput.text;

    NSString *nameString = name;
    if([nameString length] == 0) {
        nameString = @"Inigo Montoya";
    }
    NSString *greeting = [[NSString alloc] 
                          initWithFormat:@"Hello, my name is %@!", nameString];
    label.text = greeting;
    [greeting release];
}

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
    if(theTextField == textInput) {
        [textInput resignFirstResponder];
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; 
    // Release anything that's not essential, such as cached data
}

- (void)dealloc {
    [textInput release];
    [label release];
    [name release];
    [super dealloc];
}

@end

错误消息:

This GDB was configured as "x86_64-apple-darwin".Attaching to process 2668.
2011-06-09 11:20:21.662 InterfaceBuilder[2668:207] Unknown class InterfaceBuilderAppDelegate_iPhone in Interface Builder file.
2011-06-09 11:20:21.666 InterfaceBuilder[2668:207] *** Terminating app due to uncaught     exception 'NSUnknownKeyException', reason: '[<UIApplication 0x4b1a900>     setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key  textInput.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dc25a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f16313 objc_exception_throw + 44
    2   CoreFoundation                      0x00dc24e1 -[NSException raise] + 17
    3   Foundation                          0x00794677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x007945e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x0021030c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00d388cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x0020ed23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x00210ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x0001617a -[UIApplication _loadMainNibFile] + 172
    10  UIKit                               0x00016cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
    11  UIKit                               0x00021617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12  UIKit                               0x00019abf -[UIApplication sendEvent:] + 71
    13  UIKit                               0x0001ef2e _UIApplicationHandleEvent + 7576
    14  GraphicsServices                    0x00ffb992 PurpleEventCallback + 1550
    15  CoreFoundation                      0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    16  CoreFoundation                      0x00d03cf7 __CFRunLoopDoSource1 + 215
    17  CoreFoundation                      0x00d00f83 __CFRunLoopRun + 979
    18  CoreFoundation                      0x00d00840 CFRunLoopRunSpecific + 208
    19  CoreFoundation                      0x00d00761 CFRunLoopRunInMode + 97
    20  UIKit                               0x000167d2 -[UIApplication _run] + 623
    21  UIKit                               0x00022c93 UIApplicationMain + 1160
    22  InterfaceBuilder                    0x000027ff main + 127
    23  InterfaceBuilder                    0x00002775 start + 53
    24  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language:  auto; currently objective-c
(gdb) 

我是obj-c的新手,绝对拥有不知道我正在看什么关于该错误消息。任何帮助?

Im new to obj-c, and have absolutely no idea what I'm looking at in regards to that error message. Any help?

推荐答案

您的NIB / XIB文件中有错误。

You have an error in your NIB/XIB file.

看起来您之前已经附加了IBOutlet(textInput),现在连接已断开。您应该仔细检查Interface Builder中的所有连接。

It looks like you have previously attached an IBOutlet (textInput) and now the connection is broken. You should double check all connections in Interface Builder.

这篇关于目标C,线程1程序接收信号SIGABRT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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