Skip to content

Instantly share code, notes, and snippets.

@zhangkn
Last active May 4, 2018 06:58
使用dispatch_once函数能保证某段代码在程序运行过程中只被执行1次
// 使用dispatch_once函数能保证某段代码在程序运行过程中只被执行1次
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// 只执行1次的代码(这里面默认是线程安全的)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment