Skip to content

Commit

Permalink
Fixed invalid call of NSManagedObject.fetchRequest()
Browse files Browse the repository at this point in the history
Calling `NSManagedObject.fetchRequest()` is invalid:

> This method is only legal to call on **subclasses of `NSManagedObject`** that represent a single entity in the model.

https://developer.apple.com/documentation/coredata/nsmanagedobject/1640605-fetchrequest
  • Loading branch information
regexident committed Apr 13, 2018
1 parent db41d58 commit b835f84
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions templates/machine.swift.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ open class _<$sanitizedManagedObjectClassName$>: NSManagedObject {

@nonobjc
open class func fetchRequest() -> NSFetchRequest<<$sanitizedManagedObjectClassName$>> {
if #available(iOS 10.0, tvOS 10.0, watchOS 3.0, macOS 10.12, *) {
return NSManagedObject.fetchRequest() as! NSFetchRequest<<$sanitizedManagedObjectClassName$>>
} else {
return NSFetchRequest(entityName: self.entityName())
}
return NSFetchRequest(entityName: self.entityName())
}

// MARK: - Life cycle methods
Expand Down

0 comments on commit b835f84

Please sign in to comment.