Last active
February 3, 2019 20:09
-
-
Save nicol3a/db957b7376a5b263defa75c53210721a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// A `NSManagedObject` that wants to be converted from an `ObjectConvertible` object should implement the `ManagedObjectConvertible` protocol. | |
protocol ManagedObjectConvertible { | |
/// An object which should implement the `ObjectConvertible` protocol. | |
associatedtype T | |
/// A String representing a URI that provides an archiveable reference to the object in Core Data. | |
var identifier: String? { get } | |
/// Insert an object in Core Data. | |
/// | |
/// - Parameters: | |
/// - object: The object to insert. | |
/// - context: The managed object context. | |
static func insert(_ object: T, with context: NSManagedObjectContext) | |
/// Update an object in Core Data. | |
/// | |
/// - Parameters: | |
/// - object: The object to update. | |
/// - context: The managed object context. | |
static func update(_ object: T, with context: NSManagedObjectContext) | |
/// Delete an object from Core Data. | |
/// | |
/// - Parameters: | |
/// - object: The object to delete. | |
/// - context: The managed object context. | |
static func delete(_ object: T, with context: NSManagedObjectContext) | |
/// Fetch all objects from Core Data. | |
/// | |
/// - Parameter context: The managed object context. | |
/// - Returns: A list of objects. | |
static func fetchAll(from context: NSManagedObjectContext) -> [T] | |
/// Set the managed object's parameters with an object's parameters. | |
/// | |
/// - Parameter object: An object. | |
func from(object: T) | |
/// Create an object, populated with the managed object's properties. | |
/// | |
/// - Returns: An object. | |
func toObject() -> T | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment