hi i beginer in obj c
how get value in timer, my code :
- (void)viewDidLoad {
timeval =[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selectorselector(mypos) userInfo:nil repeats:YES];
[super viewDidLoad];
}
int timecount = 5;
-(void)mypos{
int posx;
posx = (arc4random() % 200)+10;
if(timecount ==5){
NSLog(@"My posx %d", posx);
}
if(timecount == 0){
NSLog(@"My posx %d", posx);
[timeval invalidate];
}
timecount = timecount -1;
}
debug :
(timecount == 5) My posx 183
(timecount == 0) My posx 96
how to get value to other class, thanks
how get value in timer, my code :
- (void)viewDidLoad {
timeval =[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selectorselector(mypos) userInfo:nil repeats:YES];
[super viewDidLoad];
}
int timecount = 5;
-(void)mypos{
int posx;
posx = (arc4random() % 200)+10;
if(timecount ==5){
NSLog(@"My posx %d", posx);
}
if(timecount == 0){
NSLog(@"My posx %d", posx);
[timeval invalidate];
}
timecount = timecount -1;
}
debug :
(timecount == 5) My posx 183
(timecount == 0) My posx 96
how to get value to other class, thanks