I am trying to learn Swift and decided to use "Swift for Dummies" published in 2015. The sample code used in the book is for XCode 6.X but I am using Xcode 7.2.1.
In chapter 4, there is a code for insertNewObject in MasterViewController.swift but it is not compatible for Xcode 7.X. The offending line is "newManagedObject.setValue.longitude = self.lastLocation.coordinate.longitude" and produces the error "Ambiguous reference to member setValue"
func insertNewObject(sender: AnyObject) {
let context = self.fetchedResultsController.managedObjectContext
let entity = self.fetchedResultsController.fetchRequest.entity!
let newManagedObject = NSEntityDescription.insertNewObjectForEntityForName("Event", inManagedObjectContext: context) as! Event
// If appropriate, configure the new managed object.
// Normally you should use accessor methods, but using KVC here avoids the need to add a custom class to the template.
newManagedObject.setValue(NSDate(), forKey: "timeStamp")
newManagedObject.latitude=self.lastLocation.coordinate.latitude
newManagedObject.setValue.longitude = self.lastLocation.coordinate.longitude
// Save the context.
do {
try context.save()
} catch {
abort()
}
}