Q:

tabelview RowInSection fatal error swift

I'm a beginner in IOS development in swift. The problem I am facing is: I am building an app using CoreData and the app contains table view and table cell. I can't really explain because of my lack of knowledge so I'm sharing screenshots. I have seen other Questions asked, none of them solved my error.  and  I have also made a function for context in AppDelegate which is
@available(iOS 10.0, *)
let ad = UIApplication.shared.delegate as! AppDelegate
@available(iOS 10.0, *)
let context = ad.persistentContainer.viewContext 

my code for VC is 
import UIKit
import CoreData

class MainVC: UIViewController, UITableViewDelegate, UITableViewDataSource, NSFetchedResultsControllerDelegate {

    @IBOutlet weak var tableViewmain: UITableView!

    @IBOutlet weak var topSegment: UISegmentedControl!

    var fetchResultControll: NSFetchedResultsController<Items>!

    override func viewDidLoad() {

        super.viewDidLoad()

        tableViewmain.delegate = self
        tableViewmain.dataSource = self

        doFetch()
    }

    func configureCell (cell: ItemsCell, indexPath: IndexPath) {

        let item = fetchResultControll.object(at: indexPath) // remember as here 
        cell.confugringCell(item: item)
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableViewmain.dequeueReusableCell(withIdentifier: "ItemsCell", for: indexPath) as! ItemsCell
        configureCell(cell: cell, indexPath: indexPath)

        return cell
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        if let sections = fetchResultControll.sections{

            let sectionInfo = sections[section]

            return sectionInfo.numberOfObjects            
        }
        return 0
    }

    func numberOfSections(in tableView: UITableView) -> Int {
        if let allSections = fetchResultControll.sections {

            return allSections.count
        }
        return 0
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 150
    }

    func doFetch() {

        let fetchRequest: NSFetchRequest<Items> = Items.fetchRequest()
        let dateSrot = NSSortDescriptor(key: "created", ascending: false)
        fetchRequest.sortDescriptors = [dateSrot]

        if #available(iOS 10.0, *) {
            let controller =  NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)    

            do {
                try controller.performFetch()
            }
            catch {                    
                let err = error as NSError
                print("\(err)")
            }

        } else {
            // Fallback on earlier versions
        }
    }
    //controler willchnge
    func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableViewmain.beginUpdates()
    }
    //controlerdidchnge
    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableViewmain.endUpdates()
    }
    //controlerdidchangeanobject
    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {

        switch(type) {

        case .insert:
            if let indexpath = newIndexPath {
                tableViewmain.insertRows(at: [indexpath], with: .fade)
            }
            break
        case .delete:
            if let indexpath = indexPath {
            tableViewmain.deleteRows(at: [indexpath], with: .fade)
            }
            break
        case .update:
            if let indexpath = indexPath {
            let cell = tableViewmain.cellForRow(at: indexpath) as! ItemsCell
            configureCell(cell: cell, indexPath: indexpath) // as used here
            }
            break
        case .move:
            if let indexpath = indexPath {
            tableViewmain.deleteRows(at: [indexpath], with: .fade)

            }
            if let indexpath = newIndexPath {
                tableViewmain.insertRows(at: [indexpath], with: .fade)
            }
            break
        }            
    }

I hope you understand me.. Any Help would be highly appreciated

A:

Replace following line with your .
var fetchResultControll: NSFetchedResultsController<Items>?

