问题
iOS 10 introduced a new class-level fetchRequest()
method in NSManagedObject
.
Like lots of other developers, I had created my own extension on NSManagedObject
which had a fetchRequest()
method.
The compiler now rightly complains about this when I'm trying to build to support iOS 10 (with a deployment target of 9.0).
What's a non-terrible way (i.e. I'm not renaming the method and all of the call points) to continue supporting iOS 9 and 10 with this codebase?
The extension currently looks like this:
extension NSManagedObject {
static func fetchRequest() -> NSFetchRequest {
return NSFetchRequest(entityName: self._entityName())
}
}
来源:https://stackoverflow.com/questions/39528071/supporting-a-nsmanagedobject-fetchrequest-class-method-in-ios-9-and-10