开发者

function that runs all the time in xcode?

开发者 https://www.devze.com 2022-12-26 01:30 出处:网络
I want to make a function that is a开发者_开发百科lways running in xcode similar to Unity\'s \"function Update()\". is this possible and if so, how.You\'ll want to read up on run loops and NSTimers.Th

I want to make a function that is a开发者_开发百科lways running in xcode similar to Unity's "function Update()". is this possible and if so, how.


You'll want to read up on run loops and NSTimers.


This code work for me,Hope it will help you!

write this function in your viewDidLoad() method

    [self performSelector:@selector(onTick:) withObject:nil afterDelay:2.0];

And Here is the onTick: Method do whatever you want to run all the time

-(void)onTick:(NSTimer *)timer
  {

  //do something here

  }
0

精彩评论

暂无评论...
验证码 换一张
取 消