Hi, I am new to iOS. Now I have confused this concept. The concept is that I want to get the current time (HH: MM: SS) when I press the button. Inside the button that I did something a recurring task using NSTimer.once, I get the current time after one minitue when NSTimer sholud invalidate (nstimer calls the call (0.05f)). Here I need to calculate the pressing time with the next minute. Sorry, I'm not mistaken, I'm stupid in English. here is the code i still have ...
- (void) scanButtonTouchUpInside {
if (check) {
position=CGPointMake(14.0f, 7.0f);
position1=CGPointMake(7.0f, 14.0f);
check=NO;
timer= [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
}
else
{
if ([timer isValid]) {
[timer invalidate];
}
check=YES;
NSLog(@"stopppppppp.....................");
}
}
-(void)onTimer
{
overlayGraphicView.center = CGPointMake(overlayGraphicView.center.x+position.x,overlayGraphicView.center.y+position.y);
if(overlayGraphicView.center.x > 320 || overlayGraphicView.center.x < 0)
position.x = -position.x;
if(overlayGraphicView.center.y > 480 || overlayGraphicView.center.y < 0)
position.y = -position.y;
overlayGraphicView1.center = CGPointMake(overlayGraphicView1.center.x+position1.x,overlayGraphicView1.center.y+position1.y);
if(overlayGraphicView1.center.x > 320 || overlayGraphicView1.center.x < 0)
position1.x = -position1.x;
if(overlayGraphicView1.center.y > 480 || overlayGraphicView1.center.y < 0)
position1.y = -position1.y;
}
source
share