From f99e225482c04e6db03ff64f191fc29fdab5f382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20C=C5=93ur?= Date: Wed, 4 Nov 2015 20:37:37 +0800 Subject: [PATCH] Comparing dispatch_get_current_queue() with dispatch_get_main_queue() is not only deprecated since iOS6, but unreliable according to queue.h When dispatch_get_current_queue() is called on the main thread, it may or may not return the same value as dispatch_get_main_queue(). Comparing the two is not a valid way to test whether code is executing on the main thread. --- algorithms-iOS/algorithms-iOS/TXSubThreadMOC.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms-iOS/algorithms-iOS/TXSubThreadMOC.m b/algorithms-iOS/algorithms-iOS/TXSubThreadMOC.m index d5071d3..c64d6d4 100644 --- a/algorithms-iOS/algorithms-iOS/TXSubThreadMOC.m +++ b/algorithms-iOS/algorithms-iOS/TXSubThreadMOC.m @@ -15,7 +15,7 @@ @implementation TXSubThreadMOC - (NSManagedObjectContext *)mocInitedOnSubThread { - NSAssert(dispatch_get_current_queue() != dispatch_get_main_queue(), @"This method should not be called from main queue"); + NSAssert(![NSThread isMainThread], @"This method should not be called from main queue"); if (mocInitedOnSubThread != nil) { return mocInitedOnSubThread;