问题描述
我刚刚安装了 Xcode 8 beta 2
和 iOS 10 beta
。我有一个现有的项目,我从swift 2.3更新到swift 3基于Xcode的提示。我收到我的代码数据代码的错误。
这是由xcode从swift 2.3转换为swift 3时自动产生的
var fetchedResultsController:NSFetchedResultsController< AnyObject> ;!
我收到的错误是
类型AnyObject不符合协议'NSFetchRequestResult'
我尝试符合AnyObject
扩展AnyObject:NSFetchRequestResult {}
但我收到另一个错误
我不知道我需要做什么,或者如果我的fetchedResultsController需要改变在第一位。
ANSWER: var fetchedResultsController:NSFetchedResultsController< Content>!
AnyObject
。 您应该打开一个雷达(bugreporter.apple.com)因为它不应该在这里建议 AnyObject
。在最坏的情况下,它应该建议 NSManagedObject
。
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.
This was auto generated in the conversion from swift 2.3 to swift 3 by xcode
var fetchedResultsController: NSFetchedResultsController<AnyObject>!
the error I'm receiving is
Type 'AnyObject' does not conform to protocol 'NSFetchRequestResult'
I tried to conform AnyObject
extension AnyObject: NSFetchRequestResult {}
But I receive another error
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<Content>!
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.
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'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!