Change CLLocationDegrees into a Double/NSNumber to save in Core Data (Swift)

Here's how to convert to NSNumber in Objective-C;

[NSNumber numberWithDouble:newLocation.coordinate.longitude]

CLLocationDegrees is a double. You shouldn't need to do anything.

If you do need to cast it to a double, use the syntax

Double(self.fixedLocation?.coordinate.latitude ?? 0)

But that should not be needed because CLLocationDegrees IS a type alias for a double.

To convert to an NSNumber, you'd use

NSNumber(value: self.fixedLocation?.coordinate.latitude ?? 0)

Edit:

I edited the code above to use the "nil coalescing operator" to give the value 0 if self.fixedLocation is nil. It would be safer to make it return an optional Int that contains a nil if the fixedLocation is nil:

let latitude: Double?
if let location = self.fixedLocation {
  latitude =     Double(location.coordinate.latitude)
} else {
  latitude = nil
}