Skip to content

Commit ca77c53

Browse files
committed
demonstrate header reuse
1 parent ecb32b8 commit ca77c53

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bk2ch08p451dynamicTableContent/ch21p718sections/RootViewController.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@
22

33
import UIKit
44

5+
func delay(delay:Double, closure:()->()) {
6+
dispatch_after(
7+
dispatch_time(
8+
DISPATCH_TIME_NOW,
9+
Int64(delay * Double(NSEC_PER_SEC))
10+
),
11+
dispatch_get_main_queue(), closure)
12+
}
13+
514
class MyHeaderView : UITableViewHeaderFooterView {
615
var section = 0
16+
// just testing reuse
17+
deinit {
18+
println ("farewell from a header, section \(section)")
19+
}
720
}
821

922
class RootViewController : UITableViewController {
@@ -38,6 +51,10 @@ class RootViewController : UITableViewController {
3851
self.tableView.sectionIndexColor = UIColor.whiteColor()
3952
self.tableView.sectionIndexBackgroundColor = UIColor.redColor()
4053
self.tableView.sectionIndexTrackingBackgroundColor = UIColor.blueColor()
54+
return // just testing reuse
55+
delay(5) {
56+
self.tableView.reloadData()
57+
}
4158
}
4259

4360
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {

0 commit comments

Comments
 (0)