WIP: readme

This commit is contained in:
John Rommel Estropia
2017-05-15 08:51:31 +09:00
parent feb0e30735
commit 91fda01071
61 changed files with 1666 additions and 1017 deletions

View File

@@ -30,28 +30,32 @@ import CoreData
// MARK: - ImportableObject
/**
`NSManagedObject` subclasses that conform to the `ImportableObject` protocol can be imported from a specified `ImportSource`. This allows transactions to create and insert instances this way:
`NSManagedObject` and `CoreStoreObject` subclasses that conform to the `ImportableObject` protocol can be imported from a specified `ImportSource`. This allows transactions to create and insert instances this way:
```
class MyPersonEntity: NSManagedObject, ImportableObject {
class Person: NSManagedObject, ImportableObject {
typealias ImportSource = NSDictionary
// ...
}
CoreStore.beginAsynchronous { (transaction) -> Void in
let json: NSDictionary = // ...
let person = try! transaction.importObject(
Into<MyPersonEntity>(),
source: json
)
// ...
transaction.commit()
}
CoreStore.perform(
asynchronous: { (transaction) -> Void in
let json: NSDictionary = // ...
let person = try transaction.importObject(
Into<Person>(),
source: json
)
// ...
},
completion: { (result) in
// ...
}
)
```
*/
public protocol ImportableObject: class {
public protocol ImportableObject: DynamicObject {
/**
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 json type, `NSDictionary`, or another external source such as `NSUserDefaults`.
*/
associatedtype ImportSource