This line of code is called in my awakeFromFetch method, located inside a custom managed object that implements NSManagedObject . This line, in particular, makes a call to my single-user network manager of the sharedManager class.
[self setSync:(![[WKNetworkManager sharedManager] objectHasPendingRequests:self.objectID]) ];
The dispatch_once block will be removed as shown below. Please note that it is implemented in good form, as shown here :

Then the dispatch_once call goes to once.h, and here it hangs right on the highlighted line:

Here is the stack trace:

All this happens when you try to load a previously saved network queue file. The application completely closes to save, and then starts again, and then this freeze / lock occurs.
I even tried using this code to solve the problem, as suggested here , and it didn't work. But changing this probably doesn't matter, since my original dispatch_once code has worked very well for a long time. It is simple in this particular case.
if ([NSThread isMainThread]) { dispatch_once(&onceToken, ^{ stack = [[KACoreDataStack alloc] init];}); } else { dispatch_sync(dispatch_get_main_queue(), ^{ dispatch_once(&onceToken, ^{ stack = [[KACoreDataStack alloc] init];}); }); }
So far, these are my sources for fixing this problem:
Thank you for your help!
ios objective-c singleton xcode grand-central-dispatch
Marcel
source share