Supporting a NSManagedObject fetchRequest() class method in iOS 9 and 10

[亡魂溺海] 提交于 2020-01-13 06:26:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!