comment documentations

This commit is contained in:
John Rommel Estropia
2016-04-03 19:47:25 +09:00
parent ab3095f078
commit dccc958ef1
54 changed files with 333 additions and 64 deletions

View File

@@ -28,22 +28,43 @@ import Foundation
// MARK: - CoreStoreObjectiveCType
/**
`CoreStoreObjectiveCType`s are Objective-C accessible classes that represent CoreStore's Swift types.
*/
public protocol CoreStoreObjectiveCType: class, AnyObject {
/**
The corresponding Swift type
*/
associatedtype SwiftType
/**
The bridged Swift instance
*/
var bridgeToSwift: SwiftType { get }
/**
Initializes this instance with the Swift instance to bridge from
*/
init(_ swiftValue: SwiftType)
}
// MARK: - CoreStoreSwiftType
/**
`CoreStoreSwiftType`s are CoreStore's Swift types that are bridgeable to Objective-C.
*/
public protocol CoreStoreSwiftType {
/**
The corresponding Objective-C type
*/
associatedtype ObjectiveCType
/**
The bridged Objective-C instance
*/
var bridgeToObjectiveC: ObjectiveCType { get }
}
@@ -107,6 +128,21 @@ internal func bridge<T: CoreStoreSwiftType>(error: NSErrorPointer, @noescape _ c
}
}
internal func bridge(error: NSErrorPointer, @noescape _ closure: () throws -> Void) -> Bool {
do {
try closure()
error.memory = nil
return true
}
catch let swiftError {
error.memory = swiftError.bridgeToObjectiveC
return false
}
}
internal func bridge<T>(error: NSErrorPointer, @noescape _ closure: () throws -> T?) -> T? {
do {