Xcode 上奇怪的编译时错误
中的代码
xcode 4.2 Game Model.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
Game Model.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 不允许使用 *' 我根本不知道这些错误! 请帮我!
code in xcode 4.2
Game Model.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
Game Model.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
I made exactly (or nearly exactly) as in a book, but I got error messages:
- implicit conversion of an Objective-C pointer to 'struct objc_class
*' is disallowed with ARC - member reference type 'struct objc_class *' is a pointer; maybe you meant to use '->'?
- incomplete definition of type 'struct objc_class' Automatic Reference Counting Issue:
- Implicit conversion of an Objective-C pointer to 'struct objc_class
*' is disallowed with ARC
I simply have no idea about these errors!
Please help me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
description
不是类方法,而是实例方法。您创建的是一个类方法:+(NSString*)description;
。您不应尝试在类方法中访问实例属性 (ivars)。将+
更改为-
。祝你好运!description
is not a class method, but an instance method. What you create is a class method:+(NSString*)description;
. You should not try to access instance properties (ivars) in a class method. Change+
into-
. Good luck!我认为您正在尝试引用此内容
,这可能会使事情变得有点混乱,尝试在没有此内容的情况下返回,看看会发生什么
I think that you are trying to refer to this
and this might mess things around a little bit, try a return without that and see what happens