Skip to content

Commit 4955f9c

Browse files
committed
update for Swift 1.2, Xcode 6.3
1 parent 57bd99a commit 4955f9c

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

bk2ch22p773location/ch35p1032location/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
1515
}
1616
let status = CLLocationManager.authorizationStatus()
1717
switch status {
18-
case .Authorized, .AuthorizedWhenInUse:
18+
case .AuthorizedAlways, .AuthorizedWhenInUse:
1919
return true
2020
case .NotDetermined:
2121
self.locman.requestWhenInUseAuthorization()
@@ -73,7 +73,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
7373

7474
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
7575
print("did update location ")
76-
let loc = locations.last as CLLocation
76+
let loc = locations.last as! CLLocation
7777
let acc = loc.horizontalAccuracy
7878
let time = loc.timestamp
7979
let coord = loc.coordinate
@@ -93,7 +93,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
9393
}
9494
// got it
9595
println("You are at \(coord.latitude) \(coord.longitude)")
96-
// self.stopTrying()
96+
self.stopTrying()
9797
}
9898

9999
}

bk2ch22p775heading/ch35p1035heading/ViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
5757

5858
func locationManagerShouldDisplayHeadingCalibration(manager: CLLocationManager!) -> Bool {
5959
return true // if you want the calibration dialog to be able to appear
60+
// I did in fact see it appear, so this works in iOS 8.3 at least
6061
}
6162

6263

bk2ch22p787gyro/ch25p1044gyro/ViewController.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ class ViewController: UIViewController {
1313
println("Oh, well")
1414
return
1515
}
16-
// idiot Swift numeric foo
17-
let ref = CMAttitudeReferenceFrameXMagneticNorthZVertical
18-
let f = ref.value
19-
let avail = UInt32(CMMotionManager.availableAttitudeReferenceFrames())
20-
if avail & f == 0 {
16+
// idiot Swift numeric foo (different in iOS 8.3 but still idiotic)
17+
let ref = CMAttitudeReferenceFrame.XMagneticNorthZVertical
18+
let avail = CMMotionManager.availableAttitudeReferenceFrames()
19+
if avail.rawValue & ref.rawValue == 0 {
2120
println("darn")
2221
return
2322
}

bk2ch22p789attitudeRotation/ch25p1046attitudeRotation/ViewController.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ class ViewController: UIViewController {
1616
println("oh well")
1717
return
1818
}
19-
let ref = CMAttitudeReferenceFrameXArbitraryCorrectedZVertical
20-
let f = ref.value
21-
let avail = UInt32(CMMotionManager.availableAttitudeReferenceFrames())
22-
if avail & f == 0 {
19+
let ref = CMAttitudeReferenceFrame.XArbitraryCorrectedZVertical
20+
let avail = CMMotionManager.availableAttitudeReferenceFrames()
21+
if avail.rawValue & ref.rawValue == 0 {
2322
println("darn")
2423
return
2524
}
@@ -53,7 +52,7 @@ class ViewController: UIViewController {
5352
t.m32 = CGFloat(r.m32)
5453
t.m33 = CGFloat(r.m33)
5554

56-
let lay = self.v.layer.sublayers[0] as CALayer
55+
let lay = self.v.layer.sublayers[0] as! CALayer
5756
CATransaction.setAnimationDuration(1.0/10.0)
5857
lay.transform = t
5958
}

bk2ch22p790motionActivity/MotionActivityTest/MyTableViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class MyTableViewController: UITableViewController {
6363
let yester = now.dateByAddingTimeInterval(-60*60*24)
6464
self.actman.queryActivityStartingFromDate(yester, toDate: now, toQueue: NSOperationQueue.mainQueue()) {
6565
(arr:[AnyObject]!, err:NSError!) -> Void in
66-
var acts = arr as [CMMotionActivity]
66+
var acts = arr as! [CMMotionActivity]
6767
// crude filter: eliminate empties, low-confidence, and successive duplicates
6868
for i in stride(from: acts.count-1, through: 0, by: -1) {
6969
if acts[i].overallAct() == "f f f f f" {
@@ -114,7 +114,7 @@ class MyTableViewController: UITableViewController {
114114
}
115115

116116
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
117-
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
117+
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
118118

119119
let act = self.data[indexPath.row]
120120
let format = NSDateFormatter()

0 commit comments

Comments
 (0)