私は、オンラインの Treehouse チュートリアルを使用して Objective C を学習している最中です。この時点まですべてを段階的に実行しましたが、ボタンを押すとエラーが発生し続けます。ここで何が間違っていたのか誰かが教えてくれることを願っています。この時点までのアプリは、ストーリーボードの上部にラベルがあり、ボタンが押されるとラベルのテキストが変更されるボタンがストーリーボードの中央にあるはずです。私のコードは以下です。
.m ファイル
//
// ViewController.m
// Prediction
//
// Created by Brandon Brown on 7/7/13.
// Copyright (c) 2013 Brandon Brown. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize predictionLabel;
- (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.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)buttonPressed:(id)sender {
self.predictionLabel.text = @"Yep";
}
@end
.h ファイル
//
// ViewController.h
// Prediction
//
// Created by Brandon Brown on 7/7/13.
// Copyright (c) 2013 Brandon Brown. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (IBAction)buttonPressed:(id)sender;
@property (strong, nonatomic) IBOutlet UILabel *predictionLabel;
@end
これは、コンソールに表示されるエラーです
2013-07-07 17:20:09.717 Prediction[14457:f803] -[UIView setText:]: unrecognized selector sent to instance 0x6a44690
2013-07-07 17:20:09.719 Prediction[14457:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setText:]: unrecognized selector sent to instance 0x6a44690'
*** First throw call stack:
(0x14b0022 0xeb0cd6 0x14b1cbd 0x1416ed0 0x1416cb2 0x22cf 0x14b1e99 0x1614e 0x160e6 0xbcade 0xbcfa7 0xbc266 0x3b3c0 0x3b5e6 0x21dc4 0x15634 0x139aef5 0x1484195 0x13e8ff2 0x13e78da 0x13e6d84 0x13e6c9b 0x13997d8 0x139988a 0x13626 0x1f0d 0x1e75)
terminate called throwing an exception