我对 Objective-C 很陌生,我正在尝试使用一些不同的代码行,这就是我到目前为止所拥有的:
CardGame.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface CardGameViewController : NSObject
@property (nonatomic) BOOL flipped;
@end
和我的
纸牌游戏.m
#import "CardGameViewController.h"
@interface CardGameViewController ()
@end
@implementation CardGameViewController
@synthesize flipped;
- (IBAction)cardButton:(UIButton *)sender {
NSLog(@"%d", flipped);
[setFlipped: true];
}
@end
Use of undeclared identifier 'setFlipped'
从我读到的内容中,我收到一条错误消息,调用@synthesize
应该在幕后创建一个 setter/getter,所以我不确定为什么这不起作用。知道如何将这个布尔值设置为 true,以及为什么我现在所拥有的不起作用?