Edit: I added my code below

I'm facing this error, which drives me crazy. Previously, I had an error message that said: 

> 
> libc++abi.dylib terminating with uncaught exception of type
>  NSException (lldb)
> 
> 
> 

and found a solution here: <https://www.youtube.com/watch?v=YMi5lPetGy4&t=220s>

However, I now have this error message: 

> 
> 2017-01-15 21:44:39.059880 بزنسي[27654:918259] [error] error: Failed
>  to load model named DreamLister CoreData: error: Failed to load model
>  named DreamLister 2017-01-15 21:44:39.191 بزنسي[27654:918259] \*\*\*
>  Terminating app due to uncaught exception
>  'NSInvalidArgumentException', reason: 'An instance of
>  NSFetchedResultsController requires a non-nil fetchRequest and
> 
> 
> 

DreamLister isn't the app i'm trying to run. So, I don't know why it's being shown when I'm trying to run a different app!! 

بزنسي is the name of the app that i'm having the issue with.

```
import UIKit
class ItemDetailsVC: UIViewController {

@IBOutlet weak var storeName: UITextField!

@IBOutlet weak var initialBalance: UITextField!

@IBOutlet weak var income: UITextField!

@IBOutlet weak var salaries: UITextField!

@IBOutlet weak var tools: UITextField!

@IBOutlet weak var maintinance: UITextField!

@IBOutlet weak var otherExpenses: UITextField!

@IBOutlet weak var expensesTotal: UILabel!

@IBOutlet weak var totalAftersubtractingExpenses: UILabel!

@IBOutlet weak var saveBtn: UIButton!
@IBOutlet weak var calBtn: UIButton!
@IBOutlet weak var orderForExpenses: UIImageView!

@IBOutlet weak var borderForTotalAfterCalc: UIImageView!

var storeToEdit: Store?

override func viewDidLoad() {
    super.viewDidLoad()

    }

    // border for expenses
    orderForExpenses.layer.borderColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0).cgColor
    orderForExpenses.layer.borderWidth = 2
    orderForExpenses.layer.cornerRadius = 5.0

    // border for total after subtracting expenses
    borderForTotalAfterCalc.layer.borderColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0).cgColor
    borderForTotalAfterCalc.layer.borderWidth = 2
    borderForTotalAfterCalc.layer.cornerRadius = 5.0

    // border for calButton
    calBtn.layer.borderWidth = 0.8
    calBtn.layer.cornerRadius = 10
    calBtn.layer.borderColor = UIColor.lightGray.cgColor

    // border for saveBtn
    saveBtn.layer.borderWidth = 0.8
    saveBtn.layer.cornerRadius = 10
    saveBtn.layer.borderColor = UIColor.lightGray.cgColor

    if storeToEdit != nil{
        loadStoreData()
    }
}

@IBAction func calButton(_ sender: Any) {

     /*let value1 = Double(income.text ?? "") ?? 0
    let value2 = Double(salaries.text ?? "") ?? 0
    let value3 = Double(tools.text ?? "") ?? 0
    let value4 = Double(maintinance.text ?? "") ?? 0
    let value5 = Double(otherExpenses.text ?? "") ?? 0
    let sum = value1 - ( value2 + value3 + value4 + value5)

    print("result is: \(sum)")*/

    let textFields = [income, salaries, tools, maintinance, otherExpenses]
    var sum = 0.0
    for textField in textFields {
        if let number = Double((textField?.text!)!) { //checks that it is not nil AND a Double
            sum += number
        }
    }

    expensesTotal.text = String(sum)
    // print("result is: \(sum)")
}

@IBAction func saveButton(_ sender: Any) {

    var store:Store!

    if storeToEdit == nil{

        store = Store(context: context)

    }else {

        store = storeToEdit
    }

    if let storeName = storeName.text{

        store.storeName = storeName
    }

    if let income = income.text{

        store.totalIncomeForStore = store.totalIncomeForStore + (income as NSString).doubleValue
    }

    ad.saveContext()

    _ = navigationController?.popViewController(animated: true)
}

func loadStoreData(){

    if let store = storeToEdit{

        storeName.text = store.storeName
        initialBalance.text = "\(store.totalIncomeForStore)"
    }
}

@IBAction func deletePressed(_ sender: UIBarButtonItem) {

    if storeToEdit != nil{

        context.delete(storeToEdit!)
        ad.saveContext()
    }

    _ = navigationController?.popViewController(animated: true)
}   
}

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

```

}

```
import UIKit
import CoreData

class MainVC: UIViewController, UITableViewDelegate, UITableViewDataSource,    NSFetchedResultsControllerDelegate {

@IBOutlet weak var tableView: UITableView!

var controler: NSFetchedResultsController<Store>!

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.delegate   = self
    tableView.dataSource = self

    // generateTestData()
    attemptFetch()

    // Do any additional setup after loading the view.
}

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

    if let sections = controler.sections{

        let sectionInfo = sections[section]
        return sectionInfo.numberOfObjects
    }

    return 0
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

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

    let cell = tableView.dequeueReusableCell(withIdentifier: "ItemCell", for: indexPath) as! ItemCell
    configureCell(cell: cell, indexpath: indexPath as NSIndexPath)

    return cell
}

func configureCell(cell: ItemCell, indexpath: NSIndexPath){

    let store = controler.object(at: indexpath as IndexPath)
    cell.configureCell(store: store)
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    if let obj = controler.fetchedObjects, obj.count > 0{

        let store = obj[indexPath.row]
        performSegue(withIdentifier: "ItemDetailsVC", sender: store)
    }
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    if segue.identifier == "ItemDetailsVC" {
        if let destination = segue.destination as? ItemDetailsVC{
            if let store = sender as? Store{
                destination.storeToEdit = store
            }
        }
    }
}

func numberOfSections(in tableView: UITableView) -> Int {

    if let sections = controler.sections{
        return sections.count
    }

    return 0
}

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

    return 86
}

func attemptFetch(){

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

    let dateSort = NSSortDescriptor(key: "created", ascending: true)

    fetchRequest.sortDescriptors = [dateSort]

    let controler = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)

    controler.delegate = self

    self.controler = controler

    do{
        try controler.performFetch()
    }catch{

        let error = error as NSError
        print("\(error)")
    }
}

func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {

    tableView.beginUpdates()

}

func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {

    tableView.endUpdates()
}

func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {

    switch(type){

        case.insert:
            if let indexPath = newIndexPath{
                tableView.insertRows(at: [indexPath], with: .fade)
            }
        break

        case.delete:
            if let indexPath = indexPath{
                tableView.deleteRows(at: [indexPath], with: .fade)
            }
        break

        case.update:
            if let indexPath = indexPath{
                let cell = tableView.cellForRow(at: indexPath) as! ItemCell
                configureCell(cell: cell, indexpath: indexPath as NSIndexPath)
            }
        break

        case.move:
            if let indexPath = indexPath{
                tableView.deleteRows(at: [indexPath], with: .fade)
            }
            if let indexPath = newIndexPath{
                tableView.insertRows(at: [indexPath], with: .fade)                    
            }
        break

    }

}

func generateTestData() {

    let store = Store(context: context)

    store.storeName = "محل رقم ١"

    let store2 = Store(context: context)

    store2.storeName = "محل رقم٢"

    let store3 = Store(context: context)

    store3.storeName = "محل رقم ٣"

    ad.saveContext()
}

```

}

```
import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

```

}