问题描述
我刚刚安装了 Xcode 8 beta 2
和 iOS 10 beta
.我有一个现有项目,我根据 Xcode 的提示从 swift 2.3 更新到 swift 3.我的代码数据代码出现错误.
I just installed Xcode 8 beta 2
and iOS 10 beta
. I have an existing project where I updated from swift 2.3 to swift 3 based on a prompt from Xcode. I received an error with my code data code.
这是在 xcode 从 swift 2.3 到 swift 3 的转换过程中自动生成的
This was auto generated in the conversion from swift 2.3 to swift 3 by xcode
var fetchedResultsController: NSFetchedResultsController<AnyObject>!
我收到的错误是
Type 'AnyObject' does not conform to protocol 'NSFetchRequestResult'
我试图符合 AnyObject
I tried to conform AnyObject
extension AnyObject: NSFetchRequestResult {}
但我收到另一个错误
我不确定我需要做什么,或者我的 fetchedResultsController 是否首先需要更改.
I am not sure what I need to do or if my fetchedResultsController needs to be changed in the first place.
ANSWER: var fetchedResultsController: NSFetchedResultsController!
推荐答案
Xcode 转换器可能对您想在此获取的结果控制器中返回什么 Entity
感到困惑.将 AnyObject
替换为您正在获取的实体类型.
The Xcode converter likely was confused about what Entity
you wanted to return in this fetched results controller. Replace AnyObject
with the entity type you are fetching.
你应该在这方面打开一个雷达 (bugreporter.apple.com),因为它不应该在这里建议 AnyObject
.在最坏的情况下,它应该建议 NSManagedObject
.
You should open a radar (bugreporter.apple.com) on this, since it should never suggest AnyObject
here. At worst it should suggest NSManagedObject
.
这篇关于类型“AnyObject"不符合协议“NSFetchRequestResult"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!