-2

Please help me there is no any specific error, run time stop

there is screenshot

func fachDataById(entityName: String, colummName: String, value: Int) -> Bool {
    let appDeleget = UIApplication.sharedApplication().delegate as! AppDelegate
    let manegeContext = appDeleget.managedObjectContext
    let fetchRequist = NSFetchRequest(entityName: entityName)
    print("ok fetchRequist")
    fetchRequist.predicate = NSPredicate(format: "%K == %@", colummName, value)

    do{
        let results = try manegeContext.executeFetchRequest(fetchRequist)
        print(results)
        return true
    }
    catch{
        print("Error")
        return false
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ayon Saha
  • 15
  • 2

1 Answers1

2

The problem is %@ format for value:Int , cast it to value as NSObject or AnyObject like following:

NSPredicate(format: "%K == %@", colummName, value as NSObject)
PANKAJ VERMA
  • 3,450
  • 1
  • 16
  • 15