fix issue with early-deallocated CoreStoreObjects

This commit is contained in:
John Estropia
2018-09-18 23:50:14 +09:00
parent 40f458a09c
commit ab40532801
8 changed files with 86 additions and 86 deletions

View File

@@ -1,7 +1,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "CoreStore" s.name = "CoreStore"
s.version = "5.3.0" s.version = "5.3.1"
s.swift_version = "4.1" s.swift_version = "4.2"
s.license = "MIT" s.license = "MIT"
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift" s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
s.homepage = "https://github.com/JohnEstropia/CoreStore" s.homepage = "https://github.com/JohnEstropia/CoreStore"

View File

@@ -41,7 +41,7 @@ internal protocol AttributeProtocol: class {
var renamingIdentifier: () -> String? { get } var renamingIdentifier: () -> String? { get }
var defaultValue: () -> Any? { get } var defaultValue: () -> Any? { get }
var affectedByKeyPaths: () -> Set<String> { get } var affectedByKeyPaths: () -> Set<String> { get }
var parentObject: CoreStoreObject? { get set } var rawObject: CoreStoreManagedObject? { get set }
var getter: CoreStoreManagedObject.CustomGetter? { get } var getter: CoreStoreManagedObject.CustomGetter? { get }
var setter: CoreStoreManagedObject.CustomSetter? { get } var setter: CoreStoreManagedObject.CustomSetter? { get }
} }

View File

@@ -93,7 +93,7 @@ open /*abstract*/ class CoreStoreObject: DynamicObject, Hashable {
} }
if lhs.isMeta { if lhs.isMeta {
return type(of: lhs) == type(of: rhs) return cs_dynamicType(of: lhs) == cs_dynamicType(of: rhs)
} }
return lhs.rawObject!.isEqual(rhs.rawObject!) return lhs.rawObject!.isEqual(rhs.rawObject!)
} }
@@ -124,10 +124,10 @@ open /*abstract*/ class CoreStoreObject: DynamicObject, Hashable {
switch child.value { switch child.value {
case let property as AttributeProtocol: case let property as AttributeProtocol:
property.parentObject = parentObject property.rawObject = parentObject.rawObject
case let property as RelationshipProtocol: case let property as RelationshipProtocol:
property.parentObject = parentObject property.rawObject = parentObject.rawObject
default: default:
continue continue

View File

@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.3.0</string> <string>5.3.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>

View File

@@ -244,23 +244,23 @@ public enum RelationshipContainer<O: CoreStoreObject> {
internal let versionHashModifier: () -> String? internal let versionHashModifier: () -> String?
internal let renamingIdentifier: () -> String? internal let renamingIdentifier: () -> String?
internal let affectedByKeyPaths: () -> Set<String> internal let affectedByKeyPaths: () -> Set<String>
internal weak var parentObject: CoreStoreObject? internal var rawObject: CoreStoreManagedObject?
internal var nativeValue: NSManagedObject? { internal var nativeValue: NSManagedObject? {
get { get {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
return object.rawObject!.getValue( return object.getValue(
forKvcKey: self.keyPath, forKvcKey: self.keyPath,
didGetValue: { $0 as! NSManagedObject? } didGetValue: { $0 as! NSManagedObject? }
) )
@@ -269,20 +269,20 @@ public enum RelationshipContainer<O: CoreStoreObject> {
set { set {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
CoreStore.assert( CoreStore.assert(
object.rawObject!.isEditableInContext() == true, object.isEditableInContext() == true,
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction." "Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
) )
object.rawObject!.setValue( object.setValue(
newValue, newValue,
forKvcKey: self.keyPath forKvcKey: self.keyPath
) )
@@ -512,23 +512,23 @@ public enum RelationshipContainer<O: CoreStoreObject> {
internal let versionHashModifier: () -> String? internal let versionHashModifier: () -> String?
internal let renamingIdentifier: () -> String? internal let renamingIdentifier: () -> String?
internal let affectedByKeyPaths: () -> Set<String> internal let affectedByKeyPaths: () -> Set<String>
internal weak var parentObject: CoreStoreObject? internal var rawObject: CoreStoreManagedObject?
internal var nativeValue: NSOrderedSet { internal var nativeValue: NSOrderedSet {
get { get {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
return object.rawObject!.getValue( return object.getValue(
forKvcKey: self.keyPath, forKvcKey: self.keyPath,
didGetValue: { ($0 as! NSOrderedSet?) ?? [] } didGetValue: { ($0 as! NSOrderedSet?) ?? [] }
) )
@@ -537,20 +537,20 @@ public enum RelationshipContainer<O: CoreStoreObject> {
set { set {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
CoreStore.assert( CoreStore.assert(
object.rawObject!.isEditableInContext() == true, object.isEditableInContext() == true,
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction." "Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
) )
object.rawObject!.setValue( object.setValue(
newValue, newValue,
forKvcKey: self.keyPath forKvcKey: self.keyPath
) )
@@ -785,23 +785,23 @@ public enum RelationshipContainer<O: CoreStoreObject> {
internal let versionHashModifier: () -> String? internal let versionHashModifier: () -> String?
internal let renamingIdentifier: () -> String? internal let renamingIdentifier: () -> String?
internal let affectedByKeyPaths: () -> Set<String> internal let affectedByKeyPaths: () -> Set<String>
internal weak var parentObject: CoreStoreObject? internal var rawObject: CoreStoreManagedObject?
internal var nativeValue: NSSet { internal var nativeValue: NSSet {
get { get {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
return object.rawObject!.getValue( return object.getValue(
forKvcKey: self.keyPath, forKvcKey: self.keyPath,
didGetValue: { ($0 as! NSSet?) ?? [] } didGetValue: { ($0 as! NSSet?) ?? [] }
) )
@@ -810,20 +810,20 @@ public enum RelationshipContainer<O: CoreStoreObject> {
set { set {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
CoreStore.assert( CoreStore.assert(
object.rawObject!.isEditableInContext() == true, object.isEditableInContext() == true,
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction." "Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
) )
object.rawObject!.setValue( object.setValue(
newValue, newValue,
forKvcKey: self.keyPath forKvcKey: self.keyPath
) )

View File

@@ -37,7 +37,7 @@ internal protocol RelationshipProtocol: class {
var deleteRule: NSDeleteRule { get } var deleteRule: NSDeleteRule { get }
var inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPathString?) { get } var inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPathString?) { get }
var affectedByKeyPaths: () -> Set<String> { get } var affectedByKeyPaths: () -> Set<String> { get }
var parentObject: CoreStoreObject? { get set } var rawObject: CoreStoreManagedObject? { get set }
var versionHashModifier: () -> String? { get } var versionHashModifier: () -> String? { get }
var renamingIdentifier: () -> String? { get } var renamingIdentifier: () -> String? { get }
var minCount: Int { get } var minCount: Int { get }

View File

@@ -145,43 +145,43 @@ public enum TransformableContainer<O: CoreStoreObject> {
get { get {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
if let customGetter = self.customGetter { if let customGetter = self.customGetter {
return customGetter(PartialObject<O>(object.rawObject!)) return customGetter(PartialObject<O>(object))
} }
return object.rawObject!.value(forKey: self.keyPath)! as! V return object.value(forKey: self.keyPath)! as! V
} }
} }
set { set {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
CoreStore.assert( CoreStore.assert(
object.rawObject!.isEditableInContext() == true, object.isEditableInContext() == true,
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction." "Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
) )
if let customSetter = self.customSetter { if let customSetter = self.customSetter {
return customSetter(PartialObject<O>(object.rawObject!), newValue) return customSetter(PartialObject<O>(object), newValue)
} }
object.rawObject!.setValue( object.setValue(
newValue, newValue,
forKey: self.keyPath forKey: self.keyPath
) )
@@ -205,7 +205,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
internal let renamingIdentifier: () -> String? internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any? internal let defaultValue: () -> Any?
internal let affectedByKeyPaths: () -> Set<String> internal let affectedByKeyPaths: () -> Set<String>
internal weak var parentObject: CoreStoreObject? internal var rawObject: CoreStoreManagedObject?
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in
@@ -358,43 +358,43 @@ public enum TransformableContainer<O: CoreStoreObject> {
get { get {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
if let customGetter = self.customGetter { if let customGetter = self.customGetter {
return customGetter(PartialObject<O>(object.rawObject!)) return customGetter(PartialObject<O>(object))
} }
return object.rawObject!.value(forKey: self.keyPath) as! V? return object.value(forKey: self.keyPath) as! V?
} }
} }
set { set {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
CoreStore.assert( CoreStore.assert(
object.rawObject!.isEditableInContext() == true, object.isEditableInContext() == true,
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction." "Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
) )
if let customSetter = self.customSetter { if let customSetter = self.customSetter {
return customSetter(PartialObject<O>(object.rawObject!), newValue) return customSetter(PartialObject<O>(object), newValue)
} }
object.rawObject!.setValue( object.setValue(
newValue, newValue,
forKey: self.keyPath forKey: self.keyPath
) )
@@ -418,7 +418,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
internal let renamingIdentifier: () -> String? internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any? internal let defaultValue: () -> Any?
internal let affectedByKeyPaths: () -> Set<String> internal let affectedByKeyPaths: () -> Set<String>
internal weak var parentObject: CoreStoreObject? internal var rawObject: CoreStoreManagedObject?
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in

View File

@@ -138,45 +138,45 @@ public enum ValueContainer<O: CoreStoreObject> {
get { get {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
if let customGetter = self.customGetter { if let customGetter = self.customGetter {
return customGetter(PartialObject<O>(object.rawObject!)) return customGetter(PartialObject<O>(object))
} }
return V.cs_fromQueryableNativeType( return V.cs_fromQueryableNativeType(
object.rawObject!.value(forKey: self.keyPath)! as! V.QueryableNativeType object.value(forKey: self.keyPath)! as! V.QueryableNativeType
)! )!
} }
} }
set { set {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
CoreStore.assert( CoreStore.assert(
object.rawObject!.isEditableInContext() == true, object.isEditableInContext() == true,
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction." "Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
) )
if let customSetter = self.customSetter { if let customSetter = self.customSetter {
return customSetter(PartialObject<O>(object.rawObject!), newValue) return customSetter(PartialObject<O>(object), newValue)
} }
return object.rawObject!.setValue( return object.setValue(
newValue.cs_toQueryableNativeType(), newValue.cs_toQueryableNativeType(),
forKey: self.keyPath forKey: self.keyPath
) )
@@ -200,7 +200,7 @@ public enum ValueContainer<O: CoreStoreObject> {
internal let renamingIdentifier: () -> String? internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any? internal let defaultValue: () -> Any?
internal let affectedByKeyPaths: () -> Set<String> internal let affectedByKeyPaths: () -> Set<String>
internal weak var parentObject: CoreStoreObject? internal var rawObject: CoreStoreManagedObject?
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in
@@ -351,44 +351,44 @@ public enum ValueContainer<O: CoreStoreObject> {
get { get {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
if let customGetter = self.customGetter { if let customGetter = self.customGetter {
return customGetter(PartialObject<O>(object.rawObject!)) return customGetter(PartialObject<O>(object))
} }
return (object.rawObject!.value(forKey: self.keyPath) as! V.QueryableNativeType?) return (object.value(forKey: self.keyPath) as! V.QueryableNativeType?)
.flatMap(V.cs_fromQueryableNativeType) .flatMap(V.cs_fromQueryableNativeType)
} }
} }
set { set {
CoreStore.assert( CoreStore.assert(
self.parentObject != nil, self.rawObject != nil,
"Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types." "Attempted to access values from a \(cs_typeName(O.self)) meta object. Meta objects are only used for querying keyPaths and infering types."
) )
return withExtendedLifetime(self.parentObject! as! O) { (object: O) in return withExtendedLifetime(self.rawObject!) { (object) in
CoreStore.assert( CoreStore.assert(
object.rawObject!.isRunningInAllowedQueue() == true, object.isRunningInAllowedQueue() == true,
"Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue." "Attempted to access \(cs_typeName(O.self))'s value outside it's designated queue."
) )
CoreStore.assert( CoreStore.assert(
object.rawObject!.isEditableInContext() == true, object.isEditableInContext() == true,
"Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction." "Attempted to update a \(cs_typeName(O.self))'s value from outside a transaction."
) )
if let customSetter = self.customSetter { if let customSetter = self.customSetter {
return customSetter(PartialObject<O>(object.rawObject!), newValue) return customSetter(PartialObject<O>(object), newValue)
} }
object.rawObject!.setValue( object.setValue(
newValue?.cs_toQueryableNativeType(), newValue?.cs_toQueryableNativeType(),
forKey: self.keyPath forKey: self.keyPath
) )
@@ -412,7 +412,7 @@ public enum ValueContainer<O: CoreStoreObject> {
internal let renamingIdentifier: () -> String? internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any? internal let defaultValue: () -> Any?
internal let affectedByKeyPaths: () -> Set<String> internal let affectedByKeyPaths: () -> Set<String>
internal weak var parentObject: CoreStoreObject? internal var rawObject: CoreStoreManagedObject?
internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in internal private(set) lazy var getter: CoreStoreManagedObject.CustomGetter? = cs_lazy { [unowned self] in