Skip to content

Commit

Permalink
Merge pull request #97 from foxling/develop
Browse files Browse the repository at this point in the history
NSManagedObjectContext.name is not available on iOS7, and fixed log for ...
  • Loading branch information
Pedro Piñera Buendía committed Dec 26, 2014
2 parents db0c75f + b5832ce commit fded462
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions library/CoreData/Base/DefaultCDStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ public class DefaultCDStack: SugarRecordStackProtocol
context = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
context!.parentContext = parentContext!
context!.addObserverToGetPermanentIDsBeforeSaving()
context!.name = "Main context"
if context!.respondsToSelector(Selector("name")) {
context!.name = "Main context"
}
SugarRecordLogger.logLevelVerbose.log("Created MAIN context")
return context!
}
Expand All @@ -309,8 +311,10 @@ public class DefaultCDStack: SugarRecordStackProtocol
context = NSManagedObjectContext(concurrencyType: .PrivateQueueConcurrencyType)
context!.persistentStoreCoordinator = persistentStoreCoordinator!
context!.addObserverToGetPermanentIDsBeforeSaving()
context!.name = "Root saving context"
SugarRecordLogger.logLevelVerbose.log("Created MAIN context")
if context!.respondsToSelector(Selector("name")) {
context!.name = "Root saving context"
}
SugarRecordLogger.logLevelVerbose.log("Created Root Saving context")
return context!
}

Expand Down Expand Up @@ -576,7 +580,7 @@ public extension NSManagedObjectContext
:param: notification Notification that fired this method call
*/
func mergeChanges(notification: NSNotification) {
SugarRecordLogger.logLevelInfo.log("Merging changes to context \(self.name)")
SugarRecordLogger.logLevelInfo.log("Merging changes to context \(self)")
self.mergeChangesFromContextDidSaveNotification(notification)
NSNotificationCenter.defaultCenter().postNotificationName(DefaultCDStack.Constants.autoSavingKVOKey, object: nil)
}
Expand Down

0 comments on commit fded462

Please sign in to comment.