title: How to update existing object in core data ? [Swift]
body: <p>I have preloaded data from a .csv file into coredata. I am fetching the data in the following way </p>
  
  <pre><code>var places:[Places] = []
  </code></pre>
  
  <p>in <code>viewDidLoad</code> : </p>
  
  <pre><code>if let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext {
              let fetchRequest = NSFetchRequest(entityName: "Places")
              do{
                  places = try managedObjectContext.executeFetchRequest(fetchRequest) as! [Places]
              }
  
              catch let error as NSError{
                  print("Failed to retrieve record: \(error.localizedDescription)")
              }
          }
  </code></pre>
  
  <p>In the data there is an attribute isFavorite of type String whose initial value is false. I am changing the value of isFavorite on button click. I want to save the changes made by the user. <strong>How can i make this change persistent ?</strong></p>
  
  <p>Here is my button action </p>
  
  <pre><code>@IBAction func addToFavourites(sender: AnyObject) {
  
          cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: sender.tag, inSection: 0)) as! CustomTableViewCell
          if cell.isFavouriteLabel.text! == "false" {
              cell.isFavouriteLabel.text = "true"
  
          }else if cell.isFavouriteLabel.text == "true"{
              cell.isFavouriteLabel.text = "false"
  
          }
  }
  </code></pre>
  
  <p>Basically i want to set the value of <code>places.isFavourite = cell.isFavoriteLabel.text</code> and save to core data</p>
  
  <p><strong>EDIT</strong> : if i try this inside my button action method </p>
  
  <pre><code>if let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext {
  
              let place : Places = Places()
              place.isFavourite = cell.isFavouriteLabel.text
               do{
                  try managedObjectContext.save()
              } catch let error as NSError{
                  print(error)
  
              }
            }
  </code></pre>
  
  <p>i am getting an <strong>error</strong> : Failed to call designated initializer on NSManagedObject class </p>
  
  <p>if i simply add this code in the button action method </p>
  
  <pre><code>places.isFavourite = cell.isFavouriteLabel.text
  </code></pre>
  
  <p>i get this <strong>error</strong> : [Places] does not have a member named isFavourite</p>