check correct queue for managed object value access

This commit is contained in:
John Estropia
2017-04-12 19:22:18 +09:00
parent 9f3db61ff7
commit a73306fecb
10 changed files with 239 additions and 40 deletions

View File

@@ -31,12 +31,29 @@ import CoreData
internal extension NSManagedObject {
@nonobjc
internal func isRunningInAllowedQueue() -> Bool? {
guard let context = self.managedObjectContext else {
return nil
}
if context.isTransactionContext {
return context.parentTransaction?.isRunningInAllowedQueue()
}
if context.isDataStackContext {
return Thread.isMainThread
}
return nil
}
// TODO: test before release (rolled back)
// @nonobjc
// internal static func cs_swizzleMethodsForLogging() {
//
//
// struct Static {
//
//
// static let isSwizzled = Static.swizzle()
//
// private static func swizzle() -> Bool {