Nit*_*oth 2 iphone objective-c
在我的iPhone应用程序中,从我想要打印NSLog的一个视图(@"Refreshed"); 在所有1分钟的间隔.我怎样才能做到这一点?
Nit*_*hel 10
使用NSTimer方式如下: -
在.h类中定义NSTimer
NSTimer*TimeOfActiveUser;
在.m
- (void)viewWillAppear:(BOOL)animated
{
TimeOfActiveUser = [NSTimer scheduledTimerWithTimeInterval:60.0 target:self selector:@selector(actionTimer) userInfo:nil repeats:YES];
}
-(void)actionTimer
{
//Print your log
}
Run Code Online (Sandbox Code Playgroud)
如果你想停止NSTIMER ..?设置另一个动作
-(void)stopTimer
{
[TimeOfActiveUser invalidate];
TimeOfActiveUser = nil;
}
Run Code Online (Sandbox Code Playgroud)
希望它的帮助是你我的朋友..快乐的编码:)
| 归档时间: |
|
| 查看次数: |
4654 次 |
| 最近记录: |