加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

需要objective-c暂停/等待功能

发布时间:2020-12-16 09:28:47 所属栏目:百科 来源:网络整理
导读:我需要在我的iPhone objective-c应用程序中添加暂停/等待功能.函数sleep()对我不起作用. 需要在这两者之间添加暂停/等待功能. myscore += [self getcard];myscore += [self getcard]; 解决方法 我没有看到Objective-c的这样一个函数,但是我使用了一个NSTimer
我需要在我的iPhone objective-c应用程序中添加暂停/等待功能.函数sleep()对我不起作用.

需要在这两者之间添加暂停/等待功能.

myscore += [self getcard];

myscore += [self getcard];

解决方法

我没有看到Objective-c的这样一个函数,但是我使用了一个NSTimer,它在你决定的时间间隔内调用给定的函数.

http://developer.apple.com/iphone/library/documentation/cocoa/reference/foundation/Classes/NSTimer_Class/Reference/NSTimer.html

更具体地说,使用函数scheduledTimerWithTimeInterval:target:selector:userInfo:重复:为我做.时间间隔是以秒为单位,每次滴答之间的“睡眠”时间,目标是持有应该调用的函数的类,选择函数.

scheduledTimerWithTimeInterval:1          // Ticks once per second
                        target:myObject   // Contains the function you want to call
                      selector:@selector(myFunction:) 
                      userInfo:nil
                       repeats:YES

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读