Created
January 8, 2019 19:39
-
-
Save kreeger/7b007253c7cb8359428ec6ca1e6bd1b6 to your computer and use it in GitHub Desktop.
Example model implementation code for the blog post "Flapjack" on O'Reilly's engineering blog.
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
extension Pancake: DataObject { | |
// The type of your primary key, if you have one of your own. | |
public typealias PrimaryKeyType = String | |
// The name of the entity as Core Data knows it. | |
public static var representedName: String { | |
return "Pancake" | |
} | |
// The key path to your model's primary key. | |
public static var primaryKeyPath: String { | |
return #keyPath(identifier) | |
} | |
// An array of sorting criteria. | |
public static var defaultSorters: [SortDescriptor] { | |
return [ | |
SortDescriptor(#keyPath(flavor), ascending: true, caseInsensitive: true), | |
SortDescriptor(#keyPath(radius), ascending: false) | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment