Asdrubal Asdrubal - 4 months ago 57
iOS Question

Type 'AnyObject' does not conform to protocol 'NSFetchRequestResult'

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

enter image description here

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>!

Answer

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.

Comments