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`.
*/
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`.

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`.
*/
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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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

View File

@@ -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

View File

@@ -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