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!
descriptionis 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!