extraño error en tiempo de compilación en Xcode

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;

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];

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!

preguntado el 08 de noviembre de 11 a las 16:11

2 Respuestas

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 + dentro -. ¡Buena suerte!

Respondido el 28 de Septiembre de 12 a las 01:09

That was exactly the problem! What I wanted to do was just overriding that method. Thank you very much! - Theemathas Chirananthavat

I think that you are trying to refer to this

[super description]

and this might mess things around a little bit, try a return without that and see what happens

return [NSString stringWithFormat:@"Player:%@. Score: %d/%d",self.playerName,self.won,self.play];

respondido 08 nov., 11:20

I didn,t found this post useful because I solved all my problems by the previous post, but thank you anyway! - Theemathas Chirananthavat

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.