swift 2.2 (Xcode 7.3 beta 4) updates

This commit is contained in:
John Estropia
2016-02-24 16:54:39 +09:00
parent 6e88b14237
commit 7bddcaa4a2
7 changed files with 27 additions and 23 deletions

View File

@@ -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`. 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`. Return `true` if an object should be created from `source`. Return `false` to ignore and skip `source`. The default implementation returns `true`.

View File

@@ -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`. 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 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 The keyPath to the entity's unique ID attribute

View File

@@ -155,11 +155,12 @@ internal extension NSManagedObjectModel {
@nonobjc internal func entityTypesMapping() -> [String: NSManagedObject.Type] { @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) mapping[entityName] = (NSClassFromString(className)! as! NSManagedObject.Type)
return mapping
} }
return mapping
} }
@nonobjc internal func mergedModels() -> [NSManagedObjectModel] { @nonobjc internal func mergedModels() -> [NSManagedObjectModel] {
@@ -249,15 +250,16 @@ internal extension NSManagedObjectModel {
return mapping as! [String: String] return mapping as! [String: String]
} }
let mapping = self.entities.reduce([String: String]()) { var mapping = [String: String]()
(var mapping, entityDescription) -> [String: String] in self.entities.forEach {
if let entityName = entityDescription.name { guard let entityName = $0.name else {
let className = entityDescription.managedObjectClassName return
mapping[className] = entityName
} }
return mapping
let className = $0.managedObjectClassName
mapping[className] = entityName
} }
setAssociatedCopiedObject( setAssociatedCopiedObject(
mapping as NSDictionary, mapping as NSDictionary,

View File

@@ -38,7 +38,7 @@ public extension CoreStore {
// MARK: Internal // 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( self.logger.log(
level: level, 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( self.logger.handleError(
error: error, 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( self.logger.assert(
condition, condition,

View File

@@ -111,15 +111,17 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
public init(dictionaryLiteral elements: (String, String)...) { public init(dictionaryLiteral elements: (String, String)...) {
var valid = true 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.") return
valid = false
} }
return versionTree
CoreStore.assert(false, "\(typeName(MigrationChain))'s migration chain could not be created due to ambiguous version paths.")
valid = false
} }
let leafVersions = Set( let leafVersions = Set(
elements.filter { (tuple: (String, String)) -> Bool in elements.filter { (tuple: (String, String)) -> Bool in

View File

@@ -45,7 +45,7 @@ public protocol ListObserver: class {
/** /**
The `NSManagedObject` type for the observed list The `NSManagedObject` type for the observed list
*/ */
typealias ListEntityType: NSManagedObject associatedtype ListEntityType: NSManagedObject
/** /**
Handles processing just before a change to the observed list occurs Handles processing just before a change to the observed list occurs

View File

@@ -42,7 +42,7 @@ public protocol ObjectObserver: class {
/** /**
The `NSManagedObject` type for the observed object The `NSManagedObject` type for the observed object
*/ */
typealias ObjectEntityType: NSManagedObject associatedtype ObjectEntityType: NSManagedObject
/** /**
Handles processing just before a change to the observed `object` occurs Handles processing just before a change to the observed `object` occurs