9

While I convert my project to swift 3.0 , I found that error

parameter 'ResultType' could not be inferred

My code like this :

let fetchRequest = NSFetchRequest(entityName: "Book")

I use this code in my project before,and now it appears error.How shell I modify it right.

Rajan Maheshwari
  • 14,465
  • 6
  • 64
  • 98

1 Answers1

12

It should be like

let fetchRequest:NSFetchRequest<Book> = Book.fetchRequest()

And your Book+CoreDataProperties.swift file for Swift 3 will be like this

import Foundation
import CoreData

extension Book {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<Book> {
        return NSFetchRequest<Book>(entityName: "Book");
    }

    @NSManaged public var bookName: String?

}
Rajan Maheshwari
  • 14,465
  • 6
  • 64
  • 98