学习笔记 - 定时器

时间:2014-07-22 23:13:43   收藏:0   阅读:458

1.可以完成的功能:每隔一段时间做一些固定的事情

2.创建定时器

1> 方法1

NSTimer *timer = [NSTimer timerWithTimeInterval:1.5 target:self selector:@selector(randomFeet) userInfo:nil repeats:YES];

[timer fire]; // 需要调用fire才能启动计时器

// fire方法只会触发一次计时器的调用

2> 方法2

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(randomFeet) userInfo:nil repeats:YES];

// 会自动创建并启动定时器,每隔1.5s,就会调用selfrandomFeet方法,scheduled:定制任务

原文:http://www.cnblogs.com/monicaios/p/3514544.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!