Last active
May 4, 2018 06:58
使用dispatch_once函数能保证某段代码在程序运行过程中只被执行1次
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 使用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