SIGABRT线程错误运行简单的ios应用程序

时间:2013-01-20 18:56:06

标签: ios xcode multithreading sigabrt

好的,所以对这样的问题有很多答案,但没有一个对我有用。基本上我写了一个非常简单的iOS应用程序,它有一个标签和一个按钮。单击按钮,标签更改。这是代码

//ViewController.h
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
- (IBAction)buttonPressed:(id)sender;
@property (strong, nonatomic) IBOutlet UILabel *predictionLabel;

@end

    //
//  ViewController.m
//  CrystalBall
//
//  
//

#import "ViewController.h"

@implementation ViewController
@synthesize predictionLabel;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [self setPredictionLabel:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
        [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
        [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)buttonPressed:(id)sender {
    self.predictionLabel.text = @"Definitley Yes!";
}
@end

当我在模拟器中运行时,应用程序打开正常,然后我单击“预测”按钮,然后它冻结,这是以绿色显示的错误

Thread 1: Program recieved signal: "SIGABRT".

沿着一条线读取         return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

调试器说: 2013-01-19 22:53:30.511 CrystalBall [441:f803] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [UIView setText:]:无法识别的选择器发送到实例0x6a19c70' * 第一次抛出调用堆栈: 2013-01-19 22:53:30.511 CrystalBall[441:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setText:]: unrecognized selector sent to instance 0x6a19c70' *** First throw call stack: (0x13b9052 0x154ad0a 0x13baced 0x131ff00 0x131fce2 0x2385 0x13baec9 0x135c2 0x1355a 0xb8b76 0xb903f 0xb82fe 0x38a30 0x38c56 0x1f384 0x12aa9 0x12a3fa9 0x138d1c5 0x12f2022 0x12f090a 0x12efdb4 0x12efccb 0x12a2879 0x12a293e 0x10a9b 0x1da8 0x1d05) terminate called throwing an exception(gdb)

希望这是足够的信息。谢谢!

1 个答案:

答案 0 :(得分:3)

      '-[UIView setText:]: unrecognized selector sent to instance 0x6a19c70'

表示您尝试将setText消息发送到UIView实例,该实例没有任何此类方法。

这可能来自声明:

  self.predictionLabel.text = @"Definitley Yes!";

所以你应该检查你如何定义predictionLabel并确保它的类型正确。

关于调试器向您显示以下这一事实:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

你应该在Xcode中定义一个异常断点来捕获所有异常:

  1. 转到左侧窗格中的“断点”标签;

  2. 在窗格底部的
  3. ,您会看到+图标;

  4. 单击它并选择添加例外断点;

  5. 确认并完成。

  6. 现在,调试器应停在导致sigabrt的实际行上,以便检查对象的状态。