1

I opened one of my projects and Xcode asked me for updating source to Swift 3. After clicking save I got as expected an error. The error occurs while creating a fetchRequest. (Error with error message in line 8)

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    let appDelegate = UIApplication.shared().delegate as! AppDelegate

    let managedContext = appDelegate.managedObjectContext!

    let fetchRequest = NSFetchRequest(entityName:"Sessions") //<- Error error message: generic parameter 'ResultType' could not be inferred

        do {
            sessions = try managedContext.fetch(fetchRequest) as! [Sessions]
        } catch let error as NSError {
            print("Could not fetch \(error), \(error.userInfo)")
        }

        print("fetched")

        self.tableView.reloadData()
    }
}
Sulthan
  • 128,090
  • 22
  • 218
  • 270

1 Answers1

1

Also got a solution for this by myself. I just changed from

let fetchRequest = NSFetchRequest(entityName:"Sessions")

to

let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName:"Sessions")

  • For more refer this link http://stackoverflow.com/questions/37810967/swift-3-nsfetchrequest?answertab=oldest#tab-top – RakeshDipuna Oct 02 '16 at 22:52