I am trying to save CLLocation data in Core Data. My property is set as a Transformable object.
Some code example indicates that location data can be saved using this objc converted to NSValue .
CLLocationCoordinate2D myLocation; NSValue *locationValue = [NSValue valueWithBytes:&myLocation objCType:@encode(CLLocationCoordinate2D)]
Retrieving an object from the data warehouse should work using this paradigm.
CLLocationCoordinate2D myLocation; NSValue *locationValue =
I am trying to extrapolate this idea and grab the entire CLLocation object in NSValue stored in CoreData in order to restore the CLLocation object from storage later.
When testing various methods, I found that nil returns when I try to unpack the CLLocation object from the master data store. I put the CLLocation object in storage using the following:
//verified that I have a good CLLocation here newManagedObject.setValue(location as CLLocation, forKey: "location")
Later I will try to deploy CLLocation
let location = detail.valueForKey("location")! as CLLocation
But I found that the object is not expanding properly.

The expanded object looks like this:
(CLLocation) location = 0x00007fff59537c90 { ObjectiveC.NSObject = {} }
Thus, any use of the CLLocation object at this point returns " nil error found ... "
Am I missing something obvious about storing / retrieving CLLocation objects using Swift?
UPDATE
Daniel's answer helped me understand that NSValueTransformer would not work for me, so I went back to the approach I used before. Basically encode the object graph with NSKeyedArchiver. My goal, as always, is to use the simplest possible solution, so I decided not to use subclasses of managed objects, since the required properties are already in the existing CLLocation object. I changed the transformable field to binary data with the check option (Save to external record file). I decided to test this process with minimal changes to the template of the main part.

Saving a graph of CLLocation objects
//assuming location is a valid CLLocation and data model has a binary data field let archivedLocation = NSKeyedArchiver.archivedDataWithRootObject(location) newManagedObject.setValue(archivedLocation, forKey: "location")
Restoring an object graph from a data warehouse
In the main vc, as the default parts are prepared for segue, data is restored through the fetch controller.
let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as NSManagedObject let controller = (segue.destinationViewController as UINavigationController).topViewController as DetailViewController controller.detailItem = object
In vc details, I expand my object graph using NSKeyedUnarchiver
var lc = NSKeyedUnarchiver.unarchiveObjectWithData(detail.valueForKey!("location") as NSData) as CLLocation