Skip to content

Commit 662765a

Browse files
committed
add massive swift coolness
1 parent 8a8457d commit 662765a

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

bk2ch08p438searchableTable/ch21p718sections/SearchResultsController.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ class SearchResultsController : UITableViewController {
1717

1818
init(data:[[String]]) {
1919
// we don't use sections, so flatten the data into a single array of strings
20-
var flattened = [String]()
21-
for arr in data {
22-
for s in arr {
23-
flattened += [s]
24-
}
25-
}
26-
self.originalData = flattened
20+
self.originalData = data.reduce([String](),+)
2721
super.init(nibName: nil, bundle: nil)
2822
}
2923

bk2ch08p438searchableTable2/ch21p718sections/SearchResultsController.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ class SearchResultsController : UITableViewController {
99

1010
func takeData(data:[[String]]) {
1111
// we don't use sections, so flatten the data into a single array of strings
12-
var flattened = [String]()
13-
for arr in data {
14-
for s in arr {
15-
flattened += [s]
16-
}
17-
}
18-
self.originalData = flattened
12+
self.originalData = data.reduce([String](),+)
1913
}
2014

2115
override func viewDidLoad() {

0 commit comments

Comments
 (0)