title: How to delete particular data from core data attribute (column) in swift 3
body: <p>I am doing core data in Swift 3. I am able to store data and able to fetch, working fine. But, while trying to delete particular data suppose string data, its not able to do.</p>
  
  <p>Following is my code</p>
  
  <pre><code>        //Delete if existing data there
          let context = DatabaseController.persistentContainer.viewContext
          let fetchRequest = NSFetchRequest&lt;NSFetchRequestResult&gt;(entityName: "UserData")
          fetchRequest.predicate = NSPredicate.init(format: "userFocusData==\(node.label.text!)")
  
          let result = try? context.fetch(fetchRequest)
          let resultData = result as! [UserData]
  
          for object in resultData {
              context.delete(object)
          }
  
          do {
              try context.save()
              print("saved!")
          } catch let error as NSError  {
              print("Could not save \(error), \(error.userInfo)")
              self.showAlert(message: "Data not able to save, please try again later.", title: kText_AppName)
          } catch {
  
          }
  </code></pre>
  
  <p>And its getting crash at following line</p>
  
  <pre><code>        let result = try? context.fetch(fetchRequest)
  </code></pre>
  
  <p>And crash report is</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath Sharepoint not found in entity &lt;NSSQLEntity UserData id=6&gt;'
  </code></pre>
  
  <p>But, I am passing some string, that string I want to delete from database.
  Can anyone suggest me, how to fix this, I have not used core data well.</p>