2011-08-30 71 views

回答

117

像這樣:[NSThread isMainThread]

+0

替代方法: - (BOOL)IsMainThread { 回報dispatch_get_main_queue()== dispatch_get_current_queue(); } –

+5

'dispatch_get_current_queue()'被棄用的iOS 6. –

+2

的**爲SWIFT 3 ** '如果Thread.isMainThread { 打印( 「主線程」) }' –