mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-22 01:19:42 +01:00
WIP: logging utilities
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
//
|
||||
// NSObject+CoreStore.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2014 John Rommel Estropia
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
internal func getAssociatedObjectForKey<T: AnyObject>(key: UnsafePointer<Void>, inObject object: AnyObject) -> T? {
|
||||
|
||||
switch objc_getAssociatedObject(object, key) {
|
||||
|
||||
case let associatedObject as T:
|
||||
return associatedObject
|
||||
|
||||
case let associatedObject as WeakObject:
|
||||
return associatedObject.object as? T
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
internal func setAssociatedRetainedObject<T: AnyObject>(associatedObject: T?, forKey key: UnsafePointer<Void>, inObject object: AnyObject) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
|
||||
internal func setAssociatedCopiedObject<T: AnyObject>(associatedObject: T?, forKey key: UnsafePointer<Void>, inObject object: AnyObject) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
||||
}
|
||||
|
||||
internal func setAssociatedAssignedObject<T: AnyObject>(associatedObject: T?, forKey key: UnsafePointer<Void>, inObject object: AnyObject) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_ASSIGN)
|
||||
}
|
||||
|
||||
internal func setAssociatedWeakObject<T: AnyObject>(associatedObject: T?, forKey key: UnsafePointer<Void>, inObject object: AnyObject) {
|
||||
|
||||
if let associatedObject = associatedObject {
|
||||
|
||||
objc_setAssociatedObject(object, key, WeakObject(associatedObject), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
else {
|
||||
|
||||
objc_setAssociatedObject(object, key, nil, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
}
|
||||
@@ -39,5 +39,6 @@ internal final class CoreStoreFetchRequest: NSFetchRequest {
|
||||
set { self.safeAffectedStores = newValue }
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
private var safeAffectedStores: [NSPersistentStore]?
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
@nonobjc
|
||||
internal convenience init<T: NSManagedObject>(dataStack: DataStack, fetchRequest: NSFetchRequest, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void) {
|
||||
|
||||
self.init(
|
||||
@@ -45,6 +46,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
||||
)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal init<T: NSManagedObject>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: (fetchRequest: NSFetchRequest) -> Void) {
|
||||
|
||||
from?.applyToFetchRequest(fetchRequest, context: context, applyAffectedStores: false)
|
||||
@@ -61,7 +63,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
||||
|
||||
guard let from = (fetchRequest.entity.flatMap { $0.managedObjectClassName }).flatMap(NSClassFromString).flatMap(From.init) else {
|
||||
|
||||
fatalError("Attempted to create an \(typeName(NSFetchedResultsController)) without a From clause or an NSEntityDescription.")
|
||||
fatalError("Attempted to create an \(cs_typeName(NSFetchedResultsController)) without a From clause or an NSEntityDescription.")
|
||||
}
|
||||
|
||||
self.reapplyAffectedStores = { fetchRequest, context in
|
||||
@@ -78,13 +80,14 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
||||
)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func performFetchFromSpecifiedStores() throws {
|
||||
|
||||
if !self.reapplyAffectedStores(fetchRequest: self.fetchRequest, context: self.managedObjectContext) {
|
||||
|
||||
CoreStore.log(
|
||||
.Warning,
|
||||
message: "Attempted to perform a fetch on an \(typeName(NSFetchedResultsController)) but could not find any persistent store for the entity \(typeName(self.fetchRequest.entityName))"
|
||||
message: "Attempted to perform a fetch on an \(cs_typeName(NSFetchedResultsController)) but could not find any persistent store for the entity \(cs_typeName(self.fetchRequest.entityName))"
|
||||
)
|
||||
}
|
||||
try self.performFetch()
|
||||
@@ -98,5 +101,6 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@nonobjc
|
||||
private let reapplyAffectedStores: (fetchRequest: NSFetchRequest, context: NSManagedObjectContext) -> Bool
|
||||
}
|
||||
|
||||
@@ -51,9 +51,13 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
@nonobjc
|
||||
internal var enabled = true
|
||||
|
||||
@nonobjc
|
||||
internal weak var handler: FetchedResultsControllerHandler?
|
||||
|
||||
@nonobjc
|
||||
internal weak var fetchedResultsController: NSFetchedResultsController? {
|
||||
|
||||
didSet {
|
||||
@@ -71,7 +75,8 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
|
||||
|
||||
// MARK: NSFetchedResultsControllerDelegate
|
||||
|
||||
@objc dynamic func controllerWillChangeContent(controller: NSFetchedResultsController) {
|
||||
@objc
|
||||
dynamic func controllerWillChangeContent(controller: NSFetchedResultsController) {
|
||||
|
||||
guard self.enabled else {
|
||||
|
||||
@@ -84,7 +89,8 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
|
||||
self.handler?.controllerWillChangeContent(controller)
|
||||
}
|
||||
|
||||
@objc dynamic func controllerDidChangeContent(controller: NSFetchedResultsController) {
|
||||
@objc
|
||||
dynamic func controllerDidChangeContent(controller: NSFetchedResultsController) {
|
||||
|
||||
guard self.enabled else {
|
||||
|
||||
@@ -94,7 +100,8 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
|
||||
self.handler?.controllerDidChangeContent(controller)
|
||||
}
|
||||
|
||||
@objc dynamic func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
|
||||
@objc
|
||||
dynamic func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
|
||||
|
||||
guard self.enabled else {
|
||||
|
||||
@@ -181,7 +188,8 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
|
||||
)
|
||||
}
|
||||
|
||||
@objc dynamic func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
|
||||
@objc
|
||||
dynamic func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
|
||||
|
||||
guard self.enabled else {
|
||||
|
||||
@@ -203,7 +211,8 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
|
||||
)
|
||||
}
|
||||
|
||||
@objc dynamic func controller(controller: NSFetchedResultsController, sectionIndexTitleForSectionName sectionName: String) -> String? {
|
||||
@objc
|
||||
dynamic func controller(controller: NSFetchedResultsController, sectionIndexTitleForSectionName sectionName: String) -> String? {
|
||||
|
||||
return self.handler?.controller(
|
||||
controller,
|
||||
@@ -214,6 +223,9 @@ internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResult
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@nonobjc
|
||||
private var deletedSections = Set<Int>()
|
||||
|
||||
@nonobjc
|
||||
private var insertedSections = Set<Int>()
|
||||
}
|
||||
|
||||
@@ -25,10 +25,18 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
internal func autoreleasepool<T>(@noescape closure: () -> T) -> T {
|
||||
|
||||
// MARK: - Custom AutoreleasePool
|
||||
|
||||
internal func cs_autoreleasepool(@noescape closure: () -> Void) {
|
||||
|
||||
autoreleasepool(closure)
|
||||
}
|
||||
|
||||
internal func cs_autoreleasepool<T>(@noescape closure: () -> T) -> T {
|
||||
|
||||
var closureValue: T!
|
||||
ObjectiveC.autoreleasepool {
|
||||
autoreleasepool {
|
||||
|
||||
closureValue = closure()
|
||||
}
|
||||
@@ -36,11 +44,11 @@ internal func autoreleasepool<T>(@noescape closure: () -> T) -> T {
|
||||
return closureValue
|
||||
}
|
||||
|
||||
internal func autoreleasepool<T>(@noescape closure: () throws -> T) throws -> T {
|
||||
internal func cs_autoreleasepool<T>(@noescape closure: () throws -> T) throws -> T {
|
||||
|
||||
var closureValue: T!
|
||||
var closureError: ErrorType?
|
||||
ObjectiveC.autoreleasepool {
|
||||
autoreleasepool {
|
||||
|
||||
do {
|
||||
|
||||
@@ -59,10 +67,10 @@ internal func autoreleasepool<T>(@noescape closure: () throws -> T) throws -> T
|
||||
return closureValue
|
||||
}
|
||||
|
||||
internal func autoreleasepool(@noescape closure: () throws -> Void) throws {
|
||||
internal func cs_autoreleasepool(@noescape closure: () throws -> Void) throws {
|
||||
|
||||
var closureError: ErrorType?
|
||||
ObjectiveC.autoreleasepool {
|
||||
autoreleasepool {
|
||||
|
||||
do {
|
||||
|
||||
@@ -79,3 +87,63 @@ internal func autoreleasepool(@noescape closure: () throws -> Void) throws {
|
||||
throw closureError
|
||||
}
|
||||
}
|
||||
|
||||
internal func cs_getAssociatedObjectForKey<T: AnyObject>(key: UnsafePointer<Void>, inObject object: AnyObject) -> T? {
|
||||
|
||||
switch objc_getAssociatedObject(object, key) {
|
||||
|
||||
case let associatedObject as T:
|
||||
return associatedObject
|
||||
|
||||
case let associatedObject as WeakObject:
|
||||
return associatedObject.object as? T
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
internal func cs_setAssociatedRetainedObject<T: AnyObject>(associatedObject: T?, forKey key: UnsafePointer<Void>, inObject object: AnyObject) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
|
||||
internal func cs_setAssociatedCopiedObject<T: AnyObject>(associatedObject: T?, forKey key: UnsafePointer<Void>, inObject object: AnyObject) {
|
||||
|
||||
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
||||
}
|
||||
|
||||
internal func cs_setAssociatedWeakObject<T: AnyObject>(associatedObject: T?, forKey key: UnsafePointer<Void>, inObject object: AnyObject) {
|
||||
|
||||
if let associatedObject = associatedObject {
|
||||
|
||||
objc_setAssociatedObject(object, key, WeakObject(associatedObject), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
else {
|
||||
|
||||
objc_setAssociatedObject(object, key, nil, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Printing Utilities
|
||||
|
||||
internal func cs_typeName<T>(value: T) -> String {
|
||||
|
||||
return "'\(String(reflecting: value.dynamicType))'"
|
||||
}
|
||||
|
||||
internal func cs_typeName<T>(value: T.Type) -> String {
|
||||
|
||||
return "'\(value)'"
|
||||
}
|
||||
|
||||
internal func cs_typeName(value: AnyClass) -> String {
|
||||
|
||||
return "'\(value)'"
|
||||
}
|
||||
|
||||
internal func cs_typeName(name: String?) -> String {
|
||||
|
||||
return "<\(name ?? "unknown")>"
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
get {
|
||||
|
||||
let number: NSNumber? = getAssociatedObjectForKey(
|
||||
let number: NSNumber? = cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.shouldCascadeSavesToParent,
|
||||
inObject: self
|
||||
)
|
||||
@@ -49,7 +49,7 @@ internal extension NSManagedObjectContext {
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedCopiedObject(
|
||||
cs_setAssociatedCopiedObject(
|
||||
NSNumber(bool: newValue),
|
||||
forKey: &PropertyKeys.shouldCascadeSavesToParent,
|
||||
inObject: self
|
||||
@@ -132,14 +132,14 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
get {
|
||||
|
||||
return getAssociatedObjectForKey(
|
||||
return cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.observerForWillSaveNotification,
|
||||
inObject: self
|
||||
)
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
newValue,
|
||||
forKey: &PropertyKeys.observerForWillSaveNotification,
|
||||
inObject: self
|
||||
|
||||
@@ -64,7 +64,7 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
CoreStore.log(
|
||||
CoreStoreError(error),
|
||||
"Failed to load existing \(typeName(object)) in context."
|
||||
"Failed to load existing \(cs_typeName(object)) in context."
|
||||
)
|
||||
return nil
|
||||
}
|
||||
@@ -341,7 +341,7 @@ internal extension NSManagedObjectContext {
|
||||
var fetchError: ErrorType?
|
||||
self.performBlockAndWait {
|
||||
|
||||
autoreleasepool {
|
||||
cs_autoreleasepool {
|
||||
|
||||
do {
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ internal extension NSManagedObjectContext {
|
||||
return parentContext.parentStack
|
||||
}
|
||||
|
||||
return getAssociatedObjectForKey(&PropertyKeys.parentStack, inObject: self)
|
||||
return cs_getAssociatedObjectForKey(&PropertyKeys.parentStack, inObject: self)
|
||||
}
|
||||
set {
|
||||
|
||||
@@ -52,7 +52,7 @@ internal extension NSManagedObjectContext {
|
||||
return
|
||||
}
|
||||
|
||||
setAssociatedWeakObject(
|
||||
cs_setAssociatedWeakObject(
|
||||
newValue,
|
||||
forKey: &PropertyKeys.parentStack,
|
||||
inObject: self
|
||||
@@ -129,14 +129,14 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
get {
|
||||
|
||||
return getAssociatedObjectForKey(
|
||||
return cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.observerForDidSaveNotification,
|
||||
inObject: self
|
||||
)
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
newValue,
|
||||
forKey: &PropertyKeys.observerForDidSaveNotification,
|
||||
inObject: self
|
||||
@@ -149,14 +149,14 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
get {
|
||||
|
||||
return getAssociatedObjectForKey(
|
||||
return cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.observerForDidImportUbiquitousContentChangesNotification,
|
||||
inObject: self
|
||||
)
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
newValue,
|
||||
forKey: &PropertyKeys.observerForDidImportUbiquitousContentChangesNotification,
|
||||
inObject: self
|
||||
|
||||
@@ -41,14 +41,14 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
get {
|
||||
|
||||
return getAssociatedObjectForKey(
|
||||
return cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.parentTransaction,
|
||||
inObject: self
|
||||
)
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedWeakObject(
|
||||
cs_setAssociatedWeakObject(
|
||||
newValue,
|
||||
forKey: &PropertyKeys.parentTransaction,
|
||||
inObject: self
|
||||
@@ -100,7 +100,7 @@ internal extension NSManagedObjectContext {
|
||||
let saveError = CoreStoreError(error)
|
||||
CoreStore.log(
|
||||
saveError,
|
||||
"Failed to save \(typeName(NSManagedObjectContext))."
|
||||
"Failed to save \(cs_typeName(NSManagedObjectContext))."
|
||||
)
|
||||
result = SaveResult(saveError)
|
||||
return
|
||||
@@ -149,7 +149,7 @@ internal extension NSManagedObjectContext {
|
||||
let saveError = CoreStoreError(error)
|
||||
CoreStore.log(
|
||||
saveError,
|
||||
"Failed to save \(typeName(NSManagedObjectContext))."
|
||||
"Failed to save \(cs_typeName(NSManagedObjectContext))."
|
||||
)
|
||||
GCDQueue.Main.async {
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ internal extension NSManagedObjectModel {
|
||||
guard let versionInfo = NSDictionary(contentsOfURL: versionInfoPlistURL),
|
||||
let versionHashes = versionInfo["NSManagedObjectModel_VersionHashes"] as? [String: AnyObject] else {
|
||||
|
||||
fatalError("Could not load \(typeName(NSManagedObjectModel)) metadata from path \"\(versionInfoPlistURL)\".")
|
||||
fatalError("Could not load \(cs_typeName(NSManagedObjectModel)) metadata from path \"\(versionInfoPlistURL)\".")
|
||||
}
|
||||
|
||||
let modelVersions = Set(versionHashes.keys)
|
||||
@@ -106,7 +106,7 @@ internal extension NSManagedObjectModel {
|
||||
return rootModel
|
||||
}
|
||||
|
||||
fatalError("Could not create an \(typeName(NSManagedObjectModel)) from the model at URL \"\(modelFileURL)\".")
|
||||
fatalError("Could not create an \(cs_typeName(NSManagedObjectModel)) from the model at URL \"\(modelFileURL)\".")
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
@@ -114,7 +114,7 @@ internal extension NSManagedObjectModel {
|
||||
|
||||
get {
|
||||
|
||||
let value: NSString? = getAssociatedObjectForKey(
|
||||
let value: NSString? = cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.currentModelVersion,
|
||||
inObject: self
|
||||
)
|
||||
@@ -122,7 +122,7 @@ internal extension NSManagedObjectModel {
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedCopiedObject(
|
||||
cs_setAssociatedCopiedObject(
|
||||
newValue == nil ? nil : (newValue! as NSString),
|
||||
forKey: &PropertyKeys.currentModelVersion,
|
||||
inObject: self
|
||||
@@ -135,7 +135,7 @@ internal extension NSManagedObjectModel {
|
||||
|
||||
get {
|
||||
|
||||
let value: NSSet? = getAssociatedObjectForKey(
|
||||
let value: NSSet? = cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.modelVersions,
|
||||
inObject: self
|
||||
)
|
||||
@@ -143,7 +143,7 @@ internal extension NSManagedObjectModel {
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedCopiedObject(
|
||||
cs_setAssociatedCopiedObject(
|
||||
newValue == nil ? nil : (newValue! as NSSet),
|
||||
forKey: &PropertyKeys.modelVersions,
|
||||
inObject: self
|
||||
@@ -235,7 +235,7 @@ internal extension NSManagedObjectModel {
|
||||
|
||||
get {
|
||||
|
||||
let value: NSURL? = getAssociatedObjectForKey(
|
||||
let value: NSURL? = cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.modelVersionFileURL,
|
||||
inObject: self
|
||||
)
|
||||
@@ -243,7 +243,7 @@ internal extension NSManagedObjectModel {
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedCopiedObject(
|
||||
cs_setAssociatedCopiedObject(
|
||||
newValue,
|
||||
forKey: &PropertyKeys.modelVersionFileURL,
|
||||
inObject: self
|
||||
@@ -256,7 +256,7 @@ internal extension NSManagedObjectModel {
|
||||
|
||||
get {
|
||||
|
||||
if let mapping: NSDictionary = getAssociatedObjectForKey(&PropertyKeys.entityNameMapping, inObject: self) {
|
||||
if let mapping: NSDictionary = cs_getAssociatedObjectForKey(&PropertyKeys.entityNameMapping, inObject: self) {
|
||||
|
||||
return mapping as! [String: String]
|
||||
}
|
||||
@@ -272,7 +272,7 @@ internal extension NSManagedObjectModel {
|
||||
let className = $0.managedObjectClassName
|
||||
mapping[className] = entityName
|
||||
}
|
||||
setAssociatedCopiedObject(
|
||||
cs_setAssociatedCopiedObject(
|
||||
mapping as NSDictionary,
|
||||
forKey: &PropertyKeys.entityNameMapping,
|
||||
inObject: self
|
||||
|
||||
@@ -38,7 +38,7 @@ internal extension NSPersistentStore {
|
||||
|
||||
get {
|
||||
|
||||
let wrapper: StorageObject? = getAssociatedObjectForKey(
|
||||
let wrapper: StorageObject? = cs_getAssociatedObjectForKey(
|
||||
&PropertyKeys.storageInterface,
|
||||
inObject: self
|
||||
)
|
||||
@@ -46,7 +46,7 @@ internal extension NSPersistentStore {
|
||||
}
|
||||
set {
|
||||
|
||||
setAssociatedRetainedObject(
|
||||
cs_setAssociatedRetainedObject(
|
||||
StorageObject(newValue),
|
||||
forKey: &PropertyKeys.storageInterface,
|
||||
inObject: self
|
||||
@@ -70,8 +70,10 @@ private class StorageObject: NSObject {
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@nonobjc
|
||||
private let storageInterface: StorageInterface?
|
||||
|
||||
@nonobjc
|
||||
private init(_ storage: StorageInterface?) {
|
||||
|
||||
self.storageInterface = storage
|
||||
|
||||
@@ -81,7 +81,7 @@ internal extension NSPersistentStoreCoordinator {
|
||||
else {
|
||||
|
||||
self.lock()
|
||||
autoreleasepool {
|
||||
cs_autoreleasepool {
|
||||
|
||||
result = closure()
|
||||
}
|
||||
@@ -129,7 +129,7 @@ internal extension NSPersistentStoreCoordinator {
|
||||
else {
|
||||
|
||||
self.lock()
|
||||
autoreleasepool {
|
||||
cs_autoreleasepool {
|
||||
|
||||
do {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user