Skip to content

Commit ce6e774

Browse files
committed
update for Swift 1.2, Xcode 6.3
1 parent 5d23813 commit ce6e774

File tree

15 files changed

+30
-31
lines changed

15 files changed

+30
-31
lines changed

bk2ch04p125imageViewAnimation/ch17p473imageViewAnimation/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ViewController : UIViewController {
1919

2020
func animate () {
2121

22-
let which = 2
22+
let which = 1
2323
switch which {
2424
case 1:
2525
let mars = UIImage(named: "Mars")!
@@ -54,7 +54,7 @@ class ViewController : UIViewController {
5454
arr += [im]
5555
}
5656
let im = UIImage.animatedImageWithImages(arr, duration:0.5)
57-
let b = UIButton.buttonWithType(.System) as UIButton
57+
let b = UIButton.buttonWithType(.System) as! UIButton
5858
b.setTitle("Howdy", forState:.Normal)
5959
b.setImage(im, forState:.Normal)
6060
b.center = CGPointMake(100,200)
@@ -63,7 +63,7 @@ class ViewController : UIViewController {
6363

6464
case 3:
6565
let im = UIImage.animatedImageNamed("pac", duration:1)
66-
let b = UIButton.buttonWithType(.System) as UIButton
66+
let b = UIButton.buttonWithType(.System) as! UIButton
6767
b.setImage(im, forState:.Normal)
6868
b.center = CGPointMake(100,200)
6969
b.sizeToFit()

bk2ch04p130viewAnimation/bk2ch04p130viewAnimation/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ViewController: UIViewController {
4040
override func viewDidLoad() {
4141
super.viewDidLoad()
4242

43-
let which = 8
43+
let which = 1
4444

4545
delay(3) {
4646
println(0)

bk2ch04p133cancelAnimation/ch17p484cancelAnimation/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ViewController : UIViewController {
1919
}
2020

2121
func cancel() {
22-
let which = 3
22+
let which = 1
2323
switch which {
2424
case 1:
2525
// simplest possible solution: just kill it dead

bk2ch04p148layerAnimation/ch17p490layerAnimation/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ViewController : UIViewController {
1010
let c = self.compassView.layer as! CompassLayer
1111
let arrow = c.arrow!
1212

13-
let which = 10
13+
let which = 1
1414
switch which {
1515
case 1:
1616
arrow.transform = CATransform3DRotate(

bk2ch04p151customAnimatableProperty/ch17p498customAnimatableProperty/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ViewController : UIViewController {
66
@IBOutlet var v : UIView!
77

88
@IBAction func doButton (sender:AnyObject) {
9-
let lay = self.v.layer as MyLayer
9+
let lay = self.v.layer as! MyLayer
1010
let cur = lay.thickness
1111
let val : CGFloat = cur == 10 ? 0 : 10
1212
lay.thickness = val

bk2ch04p157layerTransition/ch17p505layerTransition/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ViewController : UIViewController {
2121
}
2222

2323
@IBAction func doButton(sender:AnyObject?) {
24-
let lay = self.v.layer.sublayers[0] as CALayer
24+
let lay = self.v.layer.sublayers[0] as! CALayer
2525
let t = CATransition()
2626
t.type = kCATransitionPush
2727
t.subtype = kCATransitionFromBottom

bk2ch04p160frozenAnimation/FrozenAnimationTest/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ViewController: UIViewController {
3434
}
3535

3636
@IBAction func doSlider(sender: AnyObject) {
37-
let slider = sender as UISlider
37+
let slider = sender as! UISlider
3838
self.shape.timeOffset = Double(slider.value)
3939
}
4040

bk2ch04p164actions/ch17p513actions/ViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class MyAction : NSObject, CAAction {
55
arguments dict: [NSObject : AnyObject]!) {
66
let anim = CABasicAnimation(keyPath: event)
77
anim.duration = 5
8-
let lay = anObject as CALayer
8+
let lay = anObject as! CALayer
99
let newP : AnyObject? = lay.valueForKey(event)
1010
let oldP : AnyObject? = lay.presentationLayer()!.valueForKey(event)
1111
println("from \(oldP) to \(newP)")
@@ -16,9 +16,9 @@ class MyAction : NSObject, CAAction {
1616
class MyWagglePositionAction : NSObject, CAAction {
1717
func runActionForKey(event: String!, object anObject: AnyObject!,
1818
arguments dict: [NSObject : AnyObject]!) {
19-
let lay = anObject as CALayer
20-
let newP = (lay.valueForKey(event) as NSValue).CGPointValue()
21-
let oldP = (lay.presentationLayer()!.valueForKey(event) as NSValue).CGPointValue()
19+
let lay = anObject as! CALayer
20+
let newP = (lay.valueForKey(event) as! NSValue).CGPointValue()
21+
let oldP = (lay.presentationLayer()!.valueForKey(event) as! NSValue).CGPointValue()
2222

2323
let d = sqrt(pow(oldP.x - newP.x, 2) + pow(oldP.y - newP.y, 2))
2424
let r = Double(d/3.0)
@@ -56,7 +56,7 @@ class ViewController : UIViewController {
5656
@IBAction func doButton(sender:AnyObject?) {
5757
let layer = self.layer
5858

59-
let which = 10
59+
let which = 1
6060
switch which {
6161
case 1:
6262
layer.position = CGPointMake(100,100) // proving that it normally works

bk2ch04p165customAnimatableProperty2/ch17p498customAnimatableProperty/MyViewAndLayer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public extension MyLayer {
4141
let ba = CABasicAnimation(keyPath: key)
4242
// stolen directly from Apple's sample code:
4343
// sorry, guys, but I would never have thought of this!
44-
ba.fromValue = (self.presentationLayer() as CALayer).valueForKey(key)
44+
ba.fromValue = (self.presentationLayer() as! CALayer).valueForKey(key)
4545
return ba
4646
}
4747
return super.actionForKey(key)

bk2ch04p165customAnimatableProperty2/ch17p498customAnimatableProperty/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ViewController : UIViewController {
66
@IBOutlet var v : UIView!
77

88
@IBAction func doButton (sender:AnyObject) {
9-
let lay = self.v.layer as MyLayer
9+
let lay = self.v.layer as! MyLayer
1010
let cur = lay.thickness
1111
let val : CGFloat = cur == 10 ? 0 : 10
1212
CATransaction.setDisableActions(true)
@@ -17,7 +17,7 @@ class ViewController : UIViewController {
1717
}
1818

1919
@IBAction func doButton2 (sender:AnyObject) {
20-
let lay = self.v.layer as MyLayer
20+
let lay = self.v.layer as! MyLayer
2121
let cur = lay.thickness
2222
let val : CGFloat = cur == 10 ? 0 : 10
2323
lay.thickness = val // implicit

0 commit comments

Comments
 (0)