Skip to content

Commit a597ea9

Browse files
committed
more minor, shorter
1 parent a54a623 commit a597ea9

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

bk2ch06p275tabbedInterface/ch19p611tabbedInterface/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class AppDelegate : UIResponder, UIApplicationDelegate {
1515
],
1616
forState:.Normal)
1717

18-
// println((UIFont.familyNames() as [String]).map{UIFont.fontNamesForFamilyName($0)})
18+
// UIFont.familyNames()
19+
// .map{UIFont.fontNamesForFamilyName($0 as String)}.map(println)
20+
1921

2022
let ding = UIFont(name:"ZapfDingbatsITC", size:40)!
2123
UIGraphicsBeginImageContextWithOptions(CGSizeMake(100,40), false, 0)

bk2ch08p438searchableTable3/ch21p718sections/RootViewController.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,13 @@ extension RootViewController : UISearchResultsUpdating {
154154
}
155155
// we have a target string
156156
self.sectionData = self.originalSectionData.map {
157-
(sec:[String]) -> [String] in
158-
let newsec = sec.filter {
159-
s in
157+
$0.filter {
160158
let options = NSStringCompareOptions.CaseInsensitiveSearch
161-
let found = s.rangeOfString(target, options: options)
159+
let found = $0.rangeOfString(target, options: options)
162160
return (found != nil)
163161
}
164-
return newsec
165-
}.filter {$0.count > 0} // is Swift cool or what?
166-
self.sectionNames = self.sectionData.map {
167-
(sec:[String]) -> String in
168-
//return (sec[0] as NSString).substringWithRange(NSMakeRange(0,1))
169-
//I don't know, it's either that or this:
170-
return String(Array(sec[0])[0])
171-
}
162+
}.filter {$0.count > 0} // is Swift cool or what?
163+
self.sectionNames = self.sectionData.map {prefix($0[0],1)}
172164
self.tableView.reloadData()
173165
}
174166
}

bk2ch10p495dynamicType/ch23p670font1dynamicType/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class ViewController : UIViewController {
1515
super.viewDidLoad()
1616
NSNotificationCenter.defaultCenter().addObserver(self, selector: "doDynamicType:", name: UIContentSizeCategoryDidChangeNotification, object: nil)
1717

18-
// println((UIFont.familyNames() as [String])
19-
// .map{UIFont.fontNamesForFamilyName($0)})
18+
// UIFont.familyNames()
19+
// .map{UIFont.fontNamesForFamilyName($0 as String)}.map(println)
2020

2121
}
2222

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}.map {$0 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

0 commit comments

Comments
 (0)