Objective-C access to counter from another class -
i´m new objective-c , have question. don´t understand mistake.
the time counter tells me value 0.
i have game class, counter. after while when game stops screen switch end class. , in end class want print out score. not work.
game.h @interface game : cclayer { int counter; } @property (readwrite, nonatomic) int counter; +(int)returncounter; @end game.m @implementation game @synthesize counter; -(void)methodformycounter{ counter++; } +(int)returncounter{ return counter; } end.h end.m @implementation -(void)getcounter{ //here want print out counter }
the counter
property of instance of game
class, either need able access instance, or move counter location accessible both game
, end
objects. latter.
move counter
app delegate , @synthesize
it. can use anywhere want:
appdelegate *appdelegate = (appdelegate *)[[uiapplication sharedapplication] delegate]; int countervalue = [appdelegate counter];
Comments
Post a Comment