This may sound easy, but please, I am a newbie. I have a simple program that I need help resolving this issue. I would like to get the results in a method and place it into another .m file. Here is what I have:
CheckRecognizer .m
….
-(int)good {
if (fieldGoal == NO && fieldGoalPosition == 0) {
return 0;
}
else if (fieldGoal == YES && fieldGoalPosition == 1) {
return 1;
}
else if (fieldGoal == NO && fieldGoalPosition == 2) {
return 2;
}
...
}
Then I have this in my ViewController .m:
fieldGoal1 = [CheckRecognizer good];
I have #import “CheckRecognizer.h” in my file, but it won’t recognize the ‘good’ method. Can you please help? I have tried everything, like naming a variable to be accessed in the other .m file with no success. Thank you.
You’ve declared your method as an instance method, but called it as a class method. You need to instantiate an instance:
And then use it:
You should also come up with a better method name than “good.”