xcode 4.2 中的代码
游戏模型.h
#import <Foundation/Foundation.h>
@interface Game_Model : NSObject{
NSString *playerName;
int play;
int won;
}
@property (nonatomic,retain) NSString *playerName;
@property (nonatomic,readonly,assign) int play;
@property (nonatomic,readonly,assign) int won;
@end
游戏模型.m
#import "Game Model.h"
@implementation Game_Model
@synthesize playerName,play,won;
+(NSString *)description{
return [NSString stringWithFormat:@"%@. Player:%@. Score: %d/%d",[super description],self.playerName,self.won,self.play];
}
@end
我完全(或几乎完全)按照书中的方式制作,但收到错误消息:
- 将 Objective-C 指针隐式转换为“struct objc_class” *' 不允许使用 ARC
- 成员引用类型'struct objc_class *'是一个指针;也许您打算使用“->”?
- “struct objc_class”类型自动引用计数问题的不完整定义:
- 将 Objective-C 指针隐式转换为“struct objc_class” *' 不允许使用 ARC 我根本不知道这些错误! 请帮助我!
最佳答案
description
不是类方法,而是实例方法。你创建的是一个类方法:+(NSString*)description;
。您不应尝试在类方法中访问实例属性 (ivars)。把+
改成-
。祝你好运!
关于iphone - Xcode 上奇怪的编译时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8053913/