Skip to content

Commit e4528cc

Browse files
committed
update for Swift 1.2, Xcode 6.3
1 parent df3e738 commit e4528cc

File tree

18 files changed

+779
-20
lines changed

18 files changed

+779
-20
lines changed

bk2ch12p564timeConsumingNavigation/ch25p837timeConsumingNavigation/RootViewControllerTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RootViewController: UITableViewController {
2222
}
2323

2424
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
25-
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
25+
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
2626
cell.textLabel!.text = "Let’s go!"
2727
return cell
2828
}

bk2ch12p566customThermometer/ch25p840customThermometer/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ViewController: UIViewController {
6060
UIGraphicsEndImageContext()
6161
// self.prog2.progressImage = im
6262
// hacky workaround
63-
let ims = self.prog2.subviews.filter {$0 is UIImageView} as [UIImageView]
63+
let ims = self.prog2.subviews.filter {$0 is UIImageView} as! [UIImageView]
6464
ims[1].image = im
6565

6666
// but this code, which worked fine for years including iOS 7.0, was broken by iOS 7.1

bk2ch12p568pickerView/ch25p842pickerView/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class ViewController: UIViewController {
2020
override func viewDidLoad() {
2121
super.viewDidLoad()
2222
let f = NSBundle.mainBundle().pathForResource("states", ofType: "txt")!
23-
let s = NSString(contentsOfFile: f, encoding: NSUTF8StringEncoding, error: nil)!
24-
self.states = s.componentsSeparatedByString("\n") as [String]
23+
let s = String(contentsOfFile: f, encoding: NSUTF8StringEncoding, error: nil)!
24+
self.states = s.componentsSeparatedByString("\n")
2525
}
2626

2727
override func viewDidLayoutSubviews() {

bk2ch12p573searchBarFromHell/ch25p846searchBarFromHell/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ViewController: UIViewController {
4343
self.sb.searchFieldBackgroundPositionAdjustment = UIOffsetMake(0, -10) // up from center
4444

4545
// how to reach in and grab the text field
46-
for v in (self.sb.subviews[0] as UIView).subviews as [UIView] {
46+
for v in (self.sb.subviews[0] as! UIView).subviews as! [UIView] {
4747
if let tf = v as? UITextField {
4848
println("got that puppy")
4949
tf.textColor = UIColor.whiteColor()
@@ -86,7 +86,7 @@ class ViewController: UIViewController {
8686
let atts = [
8787
NSFontAttributeName: UIFont(name:"GillSans-Bold", size:16)!,
8888
NSForegroundColorAttributeName: UIColor.whiteColor(),
89-
NSShadowAttributeName: lend() {
89+
NSShadowAttributeName: lend {
9090
(shad:NSShadow) in
9191
shad.shadowColor = UIColor.grayColor()
9292
shad.shadowOffset = CGSizeMake(2,2)
@@ -100,7 +100,7 @@ class ViewController: UIViewController {
100100
}
101101

102102
extension ViewController : UISearchBarDelegate {
103-
func searchBarSearchButtonClicked(searchBar: UISearchBar!) {
103+
func searchBarSearchButtonClicked(searchBar: UISearchBar) {
104104
searchBar.resignFirstResponder()
105105
}
106106
}

bk2ch12p580stepper/ch25p853stepper/ViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ViewController: UIViewController {
2222
@IBOutlet var prog : UIProgressView!
2323

2424
@IBAction func doStep(sender:AnyObject!) {
25-
let step = sender as UIStepper
25+
let step = sender as! UIStepper
2626
self.prog.setProgress(Float(step.value / (step.maximumValue - step.minimumValue)), animated:true)
2727
}
2828

@@ -56,7 +56,7 @@ class ViewController: UIViewController {
5656
NSAttributedString(string:"\u{21DA}", attributes:[
5757
NSFontAttributeName: UIFont(name:"GillSans-Bold", size:30)!,
5858
NSForegroundColorAttributeName: UIColor.whiteColor(),
59-
NSParagraphStyleAttributeName: lend() {
59+
NSParagraphStyleAttributeName: lend {
6060
(para : NSMutableParagraphStyle) in
6161
para.alignment = .Center
6262
}
@@ -68,7 +68,7 @@ class ViewController: UIViewController {
6868
NSAttributedString(string:"\u{21DA}", attributes:[
6969
NSFontAttributeName: UIFont(name:"GillSans-Bold", size:30)!,
7070
NSForegroundColorAttributeName: UIColor.blackColor(),
71-
NSParagraphStyleAttributeName: lend() {
71+
NSParagraphStyleAttributeName: lend {
7272
(para : NSMutableParagraphStyle) in
7373
para.alignment = .Center
7474
}
@@ -80,7 +80,7 @@ class ViewController: UIViewController {
8080
NSAttributedString(string:"\u{21DA}", attributes:[
8181
NSFontAttributeName: UIFont(name:"GillSans-Bold", size:30)!,
8282
NSForegroundColorAttributeName: self.stepper.tintColor,
83-
NSParagraphStyleAttributeName: lend() {
83+
NSParagraphStyleAttributeName: lend {
8484
(para : NSMutableParagraphStyle) in
8585
para.alignment = .Center
8686
}
@@ -92,7 +92,7 @@ class ViewController: UIViewController {
9292
NSAttributedString(string:"\u{21DB}", attributes:[
9393
NSFontAttributeName: UIFont(name:"GillSans-Bold", size:30)!,
9494
NSForegroundColorAttributeName: UIColor.whiteColor(),
95-
NSParagraphStyleAttributeName: lend() {
95+
NSParagraphStyleAttributeName: lend {
9696
(para : NSMutableParagraphStyle) in
9797
para.alignment = .Center
9898
}
@@ -104,7 +104,7 @@ class ViewController: UIViewController {
104104
NSAttributedString(string:"\u{21DB}", attributes:[
105105
NSFontAttributeName: UIFont(name:"GillSans-Bold", size:30)!,
106106
NSForegroundColorAttributeName: UIColor.blackColor(),
107-
NSParagraphStyleAttributeName: lend() {
107+
NSParagraphStyleAttributeName: lend {
108108
(para : NSMutableParagraphStyle) in
109109
para.alignment = .Center
110110
}
@@ -116,7 +116,7 @@ class ViewController: UIViewController {
116116
NSAttributedString(string:"\u{21DB}", attributes:[
117117
NSFontAttributeName: UIFont(name:"GillSans-Bold", size:30)!,
118118
NSForegroundColorAttributeName: self.stepper.tintColor,
119-
NSParagraphStyleAttributeName: lend() {
119+
NSParagraphStyleAttributeName: lend {
120120
(para : NSMutableParagraphStyle) in
121121
para.alignment = .Center
122122
}

0 commit comments

Comments
 (0)