I know i have done this before, but I just cant remember how to do it.
I have a integer, that i want to be able to change in another class of mine.
how do i do it?
MainViewClass : UIViewController {
int score;
}
#import "MainViewClass.h"
OtherClass : MainViewClass{
}
Then in the .m of OtherClass i want to be able to use the variable score.
How do i do this?
I have searched around the internet, and have tried several things to try to get it to work will no success.
Thanks for looking!
Have a wonderful day.
In your MainViewClass.h, you’ll want to add your int as a property of that class.
Then in your MainViewClass.m, you’ll want to synthesize the property using:
Now since your subclassing MainViewClass in your OtherClass you can access it’s properties using some combination of the following.
In your OtherClass.h add
MainViewClass *mainViewClass;
in your OtherClass.m wherever you need access to the score, you should be able to access it as such.
and then the score using,