Xcode 5.1.1 模拟器上的应用未 运行

App not running on Xcode 5.1.1 Simulator

我是 Objective-C 的新手,我在 autoReleasepool 块中收到线程 1:信号 SIGBRT。

这是我的代码:我只向这两个文件添加了代码。我还将 3 张图片导入到支持文件夹中。

ViewController.m

//
//  ViewController.m
//  TicTacToe

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController



- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    oImg = [UIImage imageNamed:@"o.png"];
    xImg = [UIImage imageNamed:@"x.png"];
    // set the player to 1
    playerToken = 1;
    // update the label
   whoseTurn.text =@"X will go first!";
}

- (void) updatePlayerInfo{
    if(playerToken == 1) {
        playerToken = 2;
        whoseTurn.text = @"Its O's turn";
        NSLog(@"playerToken = %d", playerToken);
    }
    else if(playerToken == 2) {
        playerToken = 1;
        whoseTurn.text =@"Its X's turn";
        NSLog(@"playerToken = %d", playerToken);
    }
}
-(void) resetBoard{
    /// clear the images stored in the UIIMageView
    b1.image = NULL;
    b2.image = NULL;
    b3.image = NULL;
    b4.image = NULL;
    b5.image = NULL;
    b6.image = NULL;
    b7.image = NULL;
    b8.image = NULL;
    b9.image = NULL;
    // reset the player and update the label text
    playerToken= 1;
    whoseTurn.text = @"X goes first";
}

- (IBAction)buttonReset:(UIButton *)sender {
    [self resetBoard];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)touchesBegan:(NSSet *)touches
           withEvent:(UIEvent *)event{
    UITouch *touch = [[event allTouches] anyObject];
    if(CGRectContainsPoint([b1 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b1.image = xImg; }
        if(playerToken==2){ b1.image = oImg; }
    }
    if(CGRectContainsPoint([b2 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b2.image = xImg; }
        if(playerToken==2){ b2.image = oImg; }
    }
    if(CGRectContainsPoint([b3 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b3.image = xImg; }
        if(playerToken==2){ b3.image = oImg; }
    }
    if(CGRectContainsPoint([b4 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b4.image = xImg; }
        if(playerToken==2){ b4.image = oImg; }
    }
    if(CGRectContainsPoint([b5 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b5.image = xImg; }
        if(playerToken==2){ b5.image = oImg; }
    }
    if(CGRectContainsPoint([b6 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b6.image = xImg; }
        if(playerToken==2){ b6.image = oImg; }
    }
    if(CGRectContainsPoint([b7 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b7.image = xImg; }
        if(playerToken==2){ b7.image = oImg; }
    }
    if(CGRectContainsPoint([b8 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b8.image = xImg; }
        if(playerToken==2){ b8.image = oImg; }
    }
    if(CGRectContainsPoint([b9 frame], [touch
                                        locationInView:self.view])){
        if(playerToken==1){ b9.image = xImg; }
        if(playerToken==2){ b9.image = oImg; }
    }
    [self updatePlayerInfo];
}
@end

ViewController.h

//
//  ViewController.h
//  TicTacToe

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
    // the X or O images
    IBOutlet UIImage * oImg;
    IBOutlet UIImage * xImg;
    NSInteger playerToken;

    IBOutlet UIImageView*board;
    IBOutlet UILabel    *whoseTurn;
    IBOutlet UIButton   *resetButton;


    //UIImages X's and O's
     IBOutlet UIImageView *b1;
     IBOutlet UIImageView *b2;
     IBOutlet UIImageView *b3;
     IBOutlet UIImageView *b4;
     IBOutlet UIImageView *b5;
     IBOutlet UIImageView *b6;
     IBOutlet UIImageView *b7;
     IBOutlet UIImageView *b8;
     IBOutlet UIImageView *b9;


}

@end

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x109356bd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key sd.' ***

这通常意味着您曾经在文件中删除了一个 IBOutlet,但您忘记从 Interface Builder 中的 xib 或故事板中删除连接。查找不应该存在的名为 sd 的 属性。