Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C method not being called

It's either because of the fact I'm tired or because I'm doing it wrong, but for some reason I can't get it to call a method.

Here's what I'm trying to call:

-(void)newHighScore:(int)d

Which right now just does an NSLog saying "yea I'm working!"

I'm calling it like this:

[highscore newHighScore:score];

highscore is what I called the HighScore class in the .h, and score is an int with the score.

like image 743
Matt S. Avatar asked Mar 19 '10 02:03

Matt S.


2 Answers

Did you initialize the highscore object?

The newHighScore is an instance method, so it needs an instance of that object?

You should have, before you call the method, something along the lines of

HighScore *highscore = [[HighScore alloc] init];

Otherwise, highscore will be nil, and any messages passed to nil simply do nothing.

like image 110
executor21 Avatar answered Nov 15 '22 14:11

executor21


I'm guessing, and this is likely correct, that highscore is nil.

like image 35
Grant Paul Avatar answered Nov 15 '22 14:11

Grant Paul