Skip to content

Commit fdafd42

Browse files
authored
Merge pull request #358 from 0xpablo/patch-1
[NEW] Add specialized fetchRequest() func to Swift's machine generated files. ([0xpablo](#358))
2 parents d9f455f + f36e327 commit fdafd42

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

templates/machine.swift.motemplate

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ open class _<$sanitizedManagedObjectClassName$>: NSManagedObject {
4545
return NSEntityDescription.entity(forEntityName: self.entityName(), in: managedObjectContext)
4646
}
4747

48+
@nonobjc
49+
open class func fetchRequest() -> NSFetchRequest<<$sanitizedManagedObjectClassName$>> {
50+
if #available(iOS 10.0, tvOS 10.0, watchOS 3.0, macOS 10.12, *) {
51+
return NSManagedObject.fetchRequest() as! NSFetchRequest<<$sanitizedManagedObjectClassName$>>
52+
} else {
53+
return NSFetchRequest(entityName: self.entityName())
54+
}
55+
}
56+
4857
// MARK: - Life cycle methods
4958

5059
public override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) {

0 commit comments

Comments
 (0)