Skip to content

Commit

Permalink
d38 → Swift 1.2 (article)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Davies committed Feb 18, 2015
1 parent 35e2c32 commit fa6dffc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions 38-handoff/38-handoff.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ In __MapOff__, this method is used to get the currently visible range from the
map, and save it into the `userInfo` dictionary:

override func updateUserActivityState(activity: NSUserActivity) {
let regionData = NSData(bytes: &mapView.region, length: sizeof(MKCoordinateRegion))
let regionData = withUnsafePointer(&mapView.region) {
NSData(bytes: $0, length: sizeof(MKCoordinateRegion))
}
activity.userInfo = ["region" : regionData]
}

Expand Down Expand Up @@ -178,7 +180,7 @@ follows:
override func restoreUserActivityState(activity: NSUserActivity) {
if activity.activityType == "com.shinobicontrols.MapOff.viewport" {
// Extract the data
let regionData = activity.userInfo!["region"] as NSData
let regionData = activity.userInfo!["region"] as! NSData
// Need an empty coordinate region to populate
var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0),
span: MKCoordinateSpan(latitudeDelta: 0.0, longitudeDelta: 0.0))
Expand Down

0 comments on commit fa6dffc

Please sign in to comment.