标签:queue mat default UI idle when oid ada null
static inline void onIdleThreadAsync(void (^block)()) { if (![NSThread isMainThread]) { block(); return; } static NSOperationQueue *queue; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ queue = [NSOperationQueue new]; }); CFUUIDRef uuidRef = CFUUIDCreate(NULL); CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef); CFRelease(uuidRef); NSString *uuidValue = (__bridge NSString *)uuidStringRef; NSString *name = [NSString stringWithFormat:@"EnqueueIdleThreadNotification_%@", uuidValue]; NSNotification *notification = [NSNotification notificationWithName:name object:nil]; id __block token = [[NSNotificationCenter defaultCenter] addObserverForName:name object:nil queue:queue usingBlock:^(NSNotification * _Nonnull note) { block(); [[NSNotificationCenter defaultCenter] removeObserver:token]; }]; [[NSNotificationQueue defaultQueue] enqueueNotification:notification postingStyle:NSPostWhenIdle]; }
标签:queue mat default UI idle when oid ada null
原文地址:https://www.cnblogs.com/huangzizhu/p/9104161.html