NSTime
来源:互联网 发布:耐玩的网络游戏知乎 编辑:程序博客网 时间:2024/06/16 00:18
//第一种,自动触发定时器 { NSTimer *time = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(t:) userInfo:@{@"sdfsdf":@"df"} repeats:YES]; NSTimer *time2 = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(t:) userInfo:@"sdfsdf" repeats:YES]; //这里是提前触发,不写也会在设定间隔时间触发 [time fire]; //对应的销毁函数// [time invalidate]; } //第二种,手动触发 { NSTimer *time3 = [NSTimer timerWithTimeInterval:2 target:self selector:@selector(t:) userInfo:@"sdf" repeats:YES]; NSRunLoop *runloop=[NSRunLoop currentRunLoop]; [runloop addTimer:time3 forMode:NSDefaultRunLoopMode]; } //第三种 { //初始化一个Invocation对象 NSInvocation * invo = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(init)]]; [invo setTarget:self]; [invo setSelector:@selector(t:)]; NSTimer * timer = [NSTimer timerWithTimeInterval:1 invocation:invo repeats:YES]; //加入主循环池中 [[NSRunLoop mainRunLoop]addTimer:timer forMode:NSDefaultRunLoopMode]; //开始循环 [timer fire]; }}-(void)t:(NSTimer*)n{ //传参数 NSNumber 字典 字符串 id t = [n userInfo]; //触发的系统时间 NSData *d = n.fireDate;}
0 0
- NSTime
- NSTime bug
- 定时器NSTime用法
- Nstime延迟运行方法
- nstime 与runloop的关系
- 基于NStime计时器的实现
- About UiScrollView/NSTime/UIPageControl(2015411)
- 关于定时器NSTime与滚动视图一块运用
- iOS UITableView滑动时NSTime停止重复利用RunLoop解决
- UI基础之 -------- 轮播图 UIScrollew UIPageControll NSTime
- iOS中的三大定时器 iOS开发中定时器经常会用到,iOS中常用的定时器有三种,分别是NSTime,CADisplayLink和GCD。
- 控制台游戏 五子棋
- 【Android】Retrofit网络请求Service,@Path、@Query、@QueryMap...
- AnimatedVectorDrawable的一些碎碎念
- 第八周
- Devexpress Dxribbon风格窗体设计
- NSTime
- 博客园自定义之博客园公告栏添加时钟——利用canvas画出一个时钟
- 调用麦克风列阵进行录音
- Algorithm 第四版课后习题1.4.15(1)
- 系统各种跳转
- Javascript基础(2)
- 卷积神经网络详解
- LeetCode 88 --- Merge Sorted Array
- vs2015编译慢的解决办法