Objective C をカバーする iTunes U コースのコーディングを一緒に進めようとしています。メインファイルで
//
// main.m
// Card
//
// Created by Sid Muthal on 6/25/13.
// Copyright (c) 2013 SidMuthal. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CardGameAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([CardGameAppDelegate class]));
}
}
return UIApplicationMain(argc, argv, nil, NSStringFromClass([CardGameAppDelegate class])); を読み取る行の上に表示されます。
GDB デバッガーを使用すると、このクラッシュの次の理由が表示されます
2013-07-14 14:08:46.052 Matchgame[3148:c07] * キャッチされない例外 'NSUnknownKeyException' が原因でアプリを終了します。理由: '[ setValue:forUndefinedKey:]: このクラスは、キー Card_button のキー値コーディングに準拠していません.' * First throw call stack: (0x1c94012 0x10d1e7e 0x1d1cfb1 0xb7de41 0xaff5f8 0xaff0e7 0xb29b58 0x233019 0x10e5663 0x1c8f45a 0x231b1c 0xf67e7 0xf6dc8 0xf6ff8 0xf7232 0x463d5 0x4676f 0x46905 0xcd6eab6 0x4f917 0x1396c 0x1494b 0x25cb5 0x26beb 0x18698 0x1befdf9 0x1befad0 0x1c09bf5 0x1c09962 0x1c3abb6 0x1c39f44 0x1c39e1b 0x1417a 0x15ffc 0x20ed 0x2015) libc++abi.dylib : 例外をスローして呼び出された終了
ビューコントローラーに問題があるようです。以下は、ゲームコントローラーに使用しているコードです。
//
// CardGameViewController.m
// Card
//
// Created by Sid Muthal on 6/25/13.
// Copyright (c) 2013 SidMuthal. All rights reserved.
//
#import "CardGameViewController.h"
@interface CardGameViewController ()
@property (weak, nonatomic) IBOutlet UILabel *flipsLabel;
@property(nonatomic) int flipCount;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *cardButton;
@end
@implementation CardGameViewController
-(void)setFlipCount:(int)flipCount
{
_flipCount = flipCount;
self.flipsLabel.text = [NSString stringWithFormat:@"Flips: %d", self.flipCount];
}
- (IBAction)flipCard:(UIButton *)sender
{
sender.selected = !sender.selected;
self.flipCount++;
}
@end
以下はhファイルです。
//
// CardGameViewController.h
// Card
//
// Created by Sid Muthal on 6/25/13.
// Copyright (c) 2013 SidMuthal. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CardGameViewController: UIViewController
@end
私はしばらくこれに苦労してきたので、どんな助けでも大歓迎です。Objective C はまだ初心者です。ありがとうございます。