mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-19 07:27:02 +01:00
WIP: CSImportableUniqueObject
This commit is contained in:
@@ -33,17 +33,25 @@ import CoreData
|
||||
public protocol CSImportableObject: class, AnyObject {
|
||||
|
||||
/**
|
||||
Return `true` if an object should be created from `source`. Return `false` to ignore and skip `source`. The default implementation returns `true`.
|
||||
Return the expected class of the import source. If not implemented, transactions will not validate the import source's type.
|
||||
|
||||
- returns: the expected class of the import source
|
||||
*/
|
||||
@objc
|
||||
optional static func classForImportSource() -> AnyClass
|
||||
|
||||
/**
|
||||
Return `YES` if an object should be created from `source`. Return `NO` to ignore and skip `source`. If not implemented, transactions assume `YES`.
|
||||
|
||||
- parameter source: the object to import from
|
||||
- parameter transaction: the transaction that invoked the import. Use the transaction to fetch or create related objects if needed.
|
||||
- returns: `true` if an object should be created from `source`. Return `false` to ignore.
|
||||
- returns: `YES` if an object should be created from `source`. Return `NO` to ignore.
|
||||
*/
|
||||
@objc
|
||||
static func shouldInsertFromImportSource(source: AnyObject, inTransaction transaction: CSBaseDataTransaction) -> Bool
|
||||
optional static func shouldInsertFromImportSource(source: AnyObject, inTransaction transaction: CSBaseDataTransaction) -> Bool
|
||||
|
||||
/**
|
||||
Implements the actual importing of data from `source`. Implementers should pull values from `source` and assign them to the receiver's attributes. Note that throwing from this method will cause subsequent imports that are part of the same `importObjects(:sourceArray:)` call to be cancelled.
|
||||
Implements the actual importing of data from `source`. Implementers should pull values from `source` and assign them to the receiver's attributes. Note that throwing from this method will cause subsequent imports that are part of the same `-importObjects:sourceArray:` call to be cancelled.
|
||||
|
||||
- parameter source: the object to import from
|
||||
- parameter transaction: the transaction that invoked the import. Use the transaction to fetch or create related objects if needed.
|
||||
|
||||
@@ -36,7 +36,7 @@ import CoreData
|
||||
public final class CSSaveResult: NSObject, CoreStoreBridge {
|
||||
|
||||
/**
|
||||
`true` if the `commit` operation for the transaction succeeded, either because the save succeeded or because there were no changes to save. Returns `false` to indicate failure.
|
||||
`YES` if the `commit` operation for the transaction succeeded, either because the save succeeded or because there were no changes to save. Returns `NO` to indicate failure.
|
||||
*/
|
||||
@objc
|
||||
public var isSuccess: Bool {
|
||||
@@ -45,7 +45,7 @@ public final class CSSaveResult: NSObject, CoreStoreBridge {
|
||||
}
|
||||
|
||||
/**
|
||||
`true` if the `commit` operation for the transaction failed, or `false` otherwise. When `true`, the `error` property returns the actual `NSError` for the failure.
|
||||
`YES` if the `commit` operation for the transaction failed, or `NO` otherwise. When `YES`, the `error` property returns the actual `NSError` for the failure.
|
||||
*/
|
||||
@objc
|
||||
public var isFailure: Bool {
|
||||
@@ -54,7 +54,7 @@ public final class CSSaveResult: NSObject, CoreStoreBridge {
|
||||
}
|
||||
|
||||
/**
|
||||
`true` if the `commit` operation for the transaction succeeded and if there was an actual change made. Returns `false` otherwise.
|
||||
`YES` if the `commit` operation for the transaction succeeded and if there was an actual change made. Returns `NO` otherwise.
|
||||
*/
|
||||
@objc
|
||||
public var hasChanges: Bool {
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
/**
|
||||
Begins a child transaction where `NSManagedObject` creates, updates, and deletes can be made. This is useful for making temporary changes, such as partially filled forms.
|
||||
|
||||
To support "undo" methods such as `-undo`, `-redo`, and `-rollback`, use the `-beginSafeWithSupportsUndo:` method passing `true` to the argument. Without "undo" support, calling those methods will raise an exception.
|
||||
To support "undo" methods such as `-undo`, `-redo`, and `-rollback`, use the `-beginSafeWithSupportsUndo:` method passing `YES` to the argument. Without "undo" support, calling those methods will raise an exception.
|
||||
- returns: a `CSUnsafeDataTransaction` instance where creates, updates, and deletes can be made.
|
||||
*/
|
||||
@objc
|
||||
@@ -109,7 +109,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
/**
|
||||
Begins a child transaction where `NSManagedObject` creates, updates, and deletes can be made. This is useful for making temporary changes, such as partially filled forms.
|
||||
|
||||
- prameter supportsUndo: `-undo`, `-redo`, and `-rollback` methods are only available when this parameter is `true`, otherwise those method will raise an exception. Note that turning on Undo support may heavily impact performance especially on iOS or watchOS where memory is limited.
|
||||
- prameter supportsUndo: `-undo`, `-redo`, and `-rollback` methods are only available when this parameter is `YES`, otherwise those method will raise an exception. Note that turning on Undo support may heavily impact performance especially on iOS or watchOS where memory is limited.
|
||||
- returns: a `CSUnsafeDataTransaction` instance where creates, updates, and deletes can be made.
|
||||
*/
|
||||
@objc
|
||||
|
||||
Reference in New Issue
Block a user