mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 05:33:31 +01:00
swift 2.2 (Xcode 7.3 beta 4) updates
This commit is contained in:
@@ -53,7 +53,7 @@ public protocol ImportableObject: class {
|
||||
/**
|
||||
The data type for the import source. This is most commonly an `NSDictionary` or another external source such as an `NSUserDefaults`.
|
||||
*/
|
||||
typealias ImportSource
|
||||
associatedtype ImportSource
|
||||
|
||||
/**
|
||||
Return `true` if an object should be created from `source`. Return `false` to ignore and skip `source`. The default implementation returns `true`.
|
||||
|
||||
@@ -54,12 +54,12 @@ public protocol ImportableUniqueObject: ImportableObject {
|
||||
/**
|
||||
The data type for the import source. This is most commonly an `NSDictionary` or another external source such as an `NSUserDefaults`.
|
||||
*/
|
||||
typealias ImportSource
|
||||
associatedtype ImportSource
|
||||
|
||||
/**
|
||||
The data type for the entity's unique ID attribute
|
||||
*/
|
||||
typealias UniqueIDType: NSObject
|
||||
associatedtype UniqueIDType: NSObject
|
||||
|
||||
/**
|
||||
The keyPath to the entity's unique ID attribute
|
||||
|
||||
@@ -155,11 +155,12 @@ internal extension NSManagedObjectModel {
|
||||
|
||||
@nonobjc internal func entityTypesMapping() -> [String: NSManagedObject.Type] {
|
||||
|
||||
return self.entityNameMapping.reduce([:]) { (var mapping, pair) in
|
||||
var mapping = [String: NSManagedObject.Type]()
|
||||
self.entityNameMapping.forEach { (className, entityName) in
|
||||
|
||||
mapping[pair.1] = (NSClassFromString(pair.0)! as! NSManagedObject.Type)
|
||||
return mapping
|
||||
mapping[entityName] = (NSClassFromString(className)! as! NSManagedObject.Type)
|
||||
}
|
||||
return mapping
|
||||
}
|
||||
|
||||
@nonobjc internal func mergedModels() -> [NSManagedObjectModel] {
|
||||
@@ -249,15 +250,16 @@ internal extension NSManagedObjectModel {
|
||||
return mapping as! [String: String]
|
||||
}
|
||||
|
||||
let mapping = self.entities.reduce([String: String]()) {
|
||||
(var mapping, entityDescription) -> [String: String] in
|
||||
var mapping = [String: String]()
|
||||
self.entities.forEach {
|
||||
|
||||
if let entityName = entityDescription.name {
|
||||
guard let entityName = $0.name else {
|
||||
|
||||
let className = entityDescription.managedObjectClassName
|
||||
mapping[className] = entityName
|
||||
return
|
||||
}
|
||||
return mapping
|
||||
|
||||
let className = $0.managedObjectClassName
|
||||
mapping[className] = entityName
|
||||
}
|
||||
setAssociatedCopiedObject(
|
||||
mapping as NSDictionary,
|
||||
|
||||
@@ -38,7 +38,7 @@ public extension CoreStore {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal static func log(level: LogLevel, message: String, fileName: StaticString = __FILE__, lineNumber: Int = __LINE__, functionName: StaticString = __FUNCTION__) {
|
||||
internal static func log(level: LogLevel, message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
|
||||
|
||||
self.logger.log(
|
||||
level: level,
|
||||
@@ -49,7 +49,7 @@ public extension CoreStore {
|
||||
)
|
||||
}
|
||||
|
||||
internal static func handleError(error: NSError, _ message: String, fileName: StaticString = __FILE__, lineNumber: Int = __LINE__, functionName: StaticString = __FUNCTION__) {
|
||||
internal static func handleError(error: NSError, _ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
|
||||
|
||||
self.logger.handleError(
|
||||
error: error,
|
||||
@@ -60,7 +60,7 @@ public extension CoreStore {
|
||||
)
|
||||
}
|
||||
|
||||
internal static func assert(@autoclosure condition: () -> Bool, _ message: String, fileName: StaticString = __FILE__, lineNumber: Int = __LINE__, functionName: StaticString = __FUNCTION__) {
|
||||
internal static func assert(@autoclosure condition: () -> Bool, _ message: String, fileName: StaticString = #file, lineNumber: Int = #line, functionName: StaticString = #function) {
|
||||
|
||||
self.logger.assert(
|
||||
condition,
|
||||
|
||||
@@ -111,15 +111,17 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
|
||||
public init(dictionaryLiteral elements: (String, String)...) {
|
||||
|
||||
var valid = true
|
||||
let versionTree = elements.reduce([String: String]()) { (var versionTree, tuple: (String, String)) -> [String: String] in
|
||||
var versionTree = [String: String]()
|
||||
elements.forEach { (sourceVersion, destinationVersion) in
|
||||
|
||||
if let _ = versionTree.updateValue(tuple.1, forKey: tuple.0) {
|
||||
guard let _ = versionTree.updateValue(destinationVersion, forKey: sourceVersion) else {
|
||||
|
||||
CoreStore.assert(false, "\(typeName(MigrationChain))'s migration chain could not be created due to ambiguous version paths.")
|
||||
|
||||
valid = false
|
||||
return
|
||||
}
|
||||
return versionTree
|
||||
|
||||
CoreStore.assert(false, "\(typeName(MigrationChain))'s migration chain could not be created due to ambiguous version paths.")
|
||||
|
||||
valid = false
|
||||
}
|
||||
let leafVersions = Set(
|
||||
elements.filter { (tuple: (String, String)) -> Bool in
|
||||
|
||||
@@ -45,7 +45,7 @@ public protocol ListObserver: class {
|
||||
/**
|
||||
The `NSManagedObject` type for the observed list
|
||||
*/
|
||||
typealias ListEntityType: NSManagedObject
|
||||
associatedtype ListEntityType: NSManagedObject
|
||||
|
||||
/**
|
||||
Handles processing just before a change to the observed list occurs
|
||||
|
||||
@@ -42,7 +42,7 @@ public protocol ObjectObserver: class {
|
||||
/**
|
||||
The `NSManagedObject` type for the observed object
|
||||
*/
|
||||
typealias ObjectEntityType: NSManagedObject
|
||||
associatedtype ObjectEntityType: NSManagedObject
|
||||
|
||||
/**
|
||||
Handles processing just before a change to the observed `object` occurs
|
||||
|
||||
Reference in New Issue
Block a user