Skip to content

Instantly share code, notes, and snippets.

@bgerstle
Created February 29, 2016 17:38
Show Gist options
  • Save bgerstle/d7f518aca5c7892fc362 to your computer and use it in GitHub Desktop.
Save bgerstle/d7f518aca5c7892fc362 to your computer and use it in GitHub Desktop.
TIL: Locations don't pass NSCoding round trip (location != itself when written/read from disk)
import Foundation
import CoreLocation
let l = CLLocation(latitude: 0, longitude: 0)
let data = NSKeyedArchiver.archivedDataWithRootObject(l)
let lprime = NSKeyedUnarchiver.unarchiveObjectWithData(data) as! CLLocation
l == lprime
// $R0: Bool = false
l.description
// $R2: String = "<+0.00000000,+0.00000000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/29/16, 12:34:25 PM Eastern Standard Time"
lprime.description
// $R3: String = "<+0.00000000,+0.00000000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/29/16, 12:34:25 PM Eastern Standard Time"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment