Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJeongeui Ji
3,761 Pointsgot errors when creating a fetchedResultsController...
I just followed exactly the same as the lecturer teaches in the video but maybe I am using Swift 3 and he is using Swift 2. Please, teach me how to create a fetchedResultsController right in Swift3.
lazy var fetchedResultsController: NSFetchedResultsController = { let controller = NSFetchedResultsController(fetchRequest: self.fetchRequest, managedObjectContext: self.managedObjectContext, sectionNameKeyPath: nil, cacheName: nil) controller.delegate = self return controller }()
1 Answer
Chris Stromberg
Courses Plus Student 13,389 PointsNSFetchRequest is now a generic. NSFetchedResultsController is a generic too. Therefore, when declaring variables, you have to use a generic declaration, e.g.:
var fetchedResultsController: NSFetchedResultsController<EntityName>?