ios 目标 C,线程 1 程序接收信号 SIGABRT

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6294257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:16:32  来源:igfitidea点击:

Objective C, Thread 1 Program Received Signal SIGABRT

iosobjective-cxcode4xibsigabrt

提问by eric.mitchell

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

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

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

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;
}

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

我在第 4 行收到错误:int retVal = UI... 线程 1:程序收到信号“SIGABRT”。

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

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

Thanks!

谢谢!

Edit:

编辑:

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

Error message:

错误信息:

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) 

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

我是 obj-c 的新手,完全不知道我在看什么关于该错误消息。有什么帮助吗?

回答by jv42

You have an error in your NIB/XIB file.

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

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.

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

回答by ZhangChn

It's likely that you have set the type of 'File's Owner' incorrectly to UIViewController in your SimpleUIViewController's xib. Please set it to SimpleUIViewController in identity inspector pane.

您可能在 SimpleUIViewController 的 xib 中将“文件所有者”的类型错误地设置为 UIViewController。请在身份检查器窗格中将其设置为 SimpleUIViewController。

回答by sergio

Now I see it! Your crash report says:

现在我看到了!你的崩溃报告说:

Unknown class InterfaceBuilderAppDelegate_iPhone

So, it seems that you set your App Delegate in IB to this class, but this class is not available in your project. Check this. Either you misspelled the class name or you should add the relevant class to your project.

所以,看来你在IB中将你的App Delegate设置为这个类,但是你的项目中没有这个类。检查这个。您拼错了类名,或者您应该将相关类添加到您的项目中。

Highly likely, your text field is connected to this app delegate.

很有可能,您的文本字段已连接到此应用程序委托。

Have you connected your text field in Interface Builder to the SimpleUIViewControlleroutlet?

您是否已将 Interface Builder 中的文本字段连接到SimpleUIViewController插座?

Since it seems from the tutorial that you are not using MainWindow.xib, I would say that your project is missing running the proper delegate. Try making this change in your main:

由于从教程中似乎您没有使用 MainWindow.xib,我会说您的项目缺少运行正确的委托。尝试在您的主要内容中进行此更改:

int retVal = UIApplicationMain(argc, argv, nil, @"SimpleUIAppDelegate");

int retVal = UIApplicationMain(argc, argv, nil, @"SimpleUIAppDelegate");

If my hypothesis is right, that should move your forward.

如果我的假设是正确的,那应该会推动你前进。

回答by HenriqueAdriano

To fix it, load the XIB in Interface Builder, select the File Inspector tab, and uncheck Use autolayout. Alternatively, you can target iOS 6.0+-only devices and change the minimum target, if you absolutely must have autolayout.

要修复它,请在 Interface Builder 中加载 XIB,选择 File Inspector 选项卡,然后取消选中 Use autolayout。或者,如果您绝对必须使用自动布局,您可以针对仅 iOS 6.0+ 的设备并更改最小目标。

NSLayoutConstraint SIGABRT on iPad

iPad 上的 NSLayoutConstraint SIGABRT

回答by kiran

thread 1 program recived singal sigabrt

线程 1 程序收到信号 sigabrt

some times NSString value is goes to nill!

有时 NSString 值变为 nill!

it may cause this while initialization of your application!

它可能会在您的应用程序初始化时导致这种情况!