iOS实现代码只执行一次
程序员文章站
2023-11-27 19:39:28
ios实现代码只让执行一次
- (void)viewdidload {
[super viewdidload];
// do any addition...
ios实现代码只让执行一次
- (void)viewdidload { [super viewdidload]; // do any additional setup after loading the view, typically from a nib. [self performselector:@selector(wangmumu:) withobject:@"100" afterdelay:1]; } - (void) wangmumu:(nsstring *)han{ static dispatch_once_t hanwanjie; //只执行一次 dispatch_once(&hanwanjie, ^{ nslog(@"12345678910"); }); int niha = [han intvalue] - 1; if (niha == 10) { return; } [self performselector:@selector(hanwanjie:) withobject:[nsstring stringwithformat:@"%d",niha] afterdelay:1]; }
上一篇: IOS设计模式之组合设计模式