From a1264e0f91fdd3f7f1f6b50efe7c99e649e84073 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Wed, 14 Oct 2020 09:24:15 -0400 Subject: [PATCH] Move main thread assert to the right spot. --- platform-darwin/Source/MPAppDelegate_Store.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform-darwin/Source/MPAppDelegate_Store.m b/platform-darwin/Source/MPAppDelegate_Store.m index 25cf8f95..f71e3942 100644 --- a/platform-darwin/Source/MPAppDelegate_Store.m +++ b/platform-darwin/Source/MPAppDelegate_Store.m @@ -51,6 +51,8 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); + (NSManagedObjectContext *)managedObjectContextForMainThreadIfReady { + NSAssert( [[NSThread currentThread] isMainThread], @"Direct access to main MOC only allowed from the main thread." ); + NSManagedObjectContext *mainManagedObjectContext = [[self get] mainManagedObjectContextIfReady]; if (!mainManagedObjectContext || ![[NSThread currentThread] isMainThread]) return nil; @@ -154,8 +156,6 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); - (NSManagedObjectContext *)mainManagedObjectContextIfReady { - NSAssert( [[NSThread currentThread] isMainThread], @"Can only access main MOC from the main thread." ); - [self loadStore]; if (!self.mainManagedObjectContext && self.privateManagedObjectContext.persistentStoreCoordinator) {