使用GCD

dispatch_once_t必須是全局或static變量css 非全局或非static的dispatch_once_t變量在使用時會致使很是很差排查的bug,正確的以下:web //靜態變量,保證只有一份實例,才能確保只執行一次 static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ //單例代碼 }); 其實就是保
相關文章
相關標籤/搜索