WIP: SaveResult bridge

This commit is contained in:
John Rommel Estropia
2016-03-25 07:57:09 +09:00
parent 90369cf994
commit 707445a169
11 changed files with 189 additions and 59 deletions

View File

@@ -29,7 +29,7 @@ import CoreData
// MARK: - CoreStoreError
public enum CoreStoreError: ErrorType, CustomStringConvertible, CustomDebugStringConvertible, Equatable {
public enum CoreStoreError: ErrorType, CustomStringConvertible, CustomDebugStringConvertible, Hashable {
/**
A failure occured because of an unknown error.
@@ -94,6 +94,31 @@ public enum CoreStoreError: ErrorType, CustomStringConvertible, CustomDebugStrin
}
// MARK: Hashable
public var hashValue: Int {
let code = self._code
switch self {
case .Unknown:
return code.hashValue
case .DifferentStorageExistsAtURL(let existingPersistentStoreURL):
return code.hashValue ^ existingPersistentStoreURL.hashValue
case .MappingModelNotFound(let localStoreURL, let targetModel, let targetModelVersion):
return code.hashValue ^ localStoreURL.hashValue ^ targetModel.hashValue ^ targetModelVersion.hashValue
case .ProgressiveMigrationRequired(let localStoreURL):
return code.hashValue ^ localStoreURL.hashValue
case .InternalError(let NSError):
return code.hashValue ^ NSError.hashValue
}
}
// MARK: Internal
internal init(_ error: ErrorType?) {