Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 610
Asdrubal Avatar asked Jul 11 '16 15:07

Asdrubal


1 Answers

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.

like image 127
Rob Napier Avatar answered Nov 08 '22 04:11

Rob Napier