Reputation: 681
In my view controller I call with a reference to game, which is an istance of Game class
score.text = [NSString stringWithFormat:@"%d", [game score]];
Game has this:
int score
@property (nonatomic, readwrite) int *score ;
son normally score has a getter. Game.h is included in ViewController.h
Why do I get "unrecognized selector sent to instance"?
Upvotes: 0
Views: 311
Reputation: 16530
Did you synthesize it in your implementation?
@synthesize score;
Also, you do not want a pointer to an int, but an int itself. Remove the '*'.
Thirdly, I'm assuming score.text
is setting the text for a UILabel
or similar? And is different from Game's score
.
Another check you can use is to make use of dot-notation. If the property is not properly set, you will get an error rather than a warning. I.e. game.score
instead of [game score]
.
Upvotes: 1
Reputation: 9810
Not sure, if thats a typo, but the property declaration of score doesn't need an asterisk, as its a primitive type, so that could definitely be the issue.
Upvotes: 0
Reputation: 25692
score.text = [NSString stringWithFormat:@"%d", [game score]];//u can use %i instead %d
int score
@property (nonatomic, readwrite) int score ;//remove here ur star
or
@property (nonatomic) int score ;//remove here ur star
Upvotes: 1