mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-09 19:03:35 +02:00
provide a way to enumerate entities managed by the DataStack
This commit is contained in:
@@ -150,6 +150,15 @@ internal extension NSManagedObjectModel {
|
|||||||
return self.entityNameMapping[NSStringFromClass(entityClass)]!
|
return self.entityNameMapping[NSStringFromClass(entityClass)]!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@nonobjc internal func entityMapping() -> [String: NSManagedObject.Type] {
|
||||||
|
|
||||||
|
return self.entityNameMapping.reduce([:]) { (var mapping, pair) in
|
||||||
|
|
||||||
|
mapping[pair.0] = (NSClassFromString(pair.1)! as! NSManagedObject.Type)
|
||||||
|
return mapping
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@nonobjc internal func mergedModels() -> [NSManagedObjectModel] {
|
@nonobjc internal func mergedModels() -> [NSManagedObjectModel] {
|
||||||
|
|
||||||
return self.modelVersions?.map { self[$0] }.flatMap { $0 == nil ? [] : [$0!] } ?? [self]
|
return self.modelVersions?.map { self[$0] }.flatMap { $0 == nil ? [] : [$0!] } ?? [self]
|
||||||
|
|||||||
@@ -81,6 +81,14 @@ public final class DataStack {
|
|||||||
return self.model.currentModelVersion!
|
return self.model.currentModelVersion!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the entity name-to-class type mapping from the `DataStack`'s model.
|
||||||
|
*/
|
||||||
|
public var entitiesByName: [String: NSManagedObject.Type] {
|
||||||
|
|
||||||
|
return self.model.entityMapping()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds an in-memory store to the stack.
|
Adds an in-memory store to the stack.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user