Update Sample View Controller

This commit is contained in:
Adlai Holler
2016-02-01 11:04:39 -08:00
parent 836ab9c17f
commit 67212c69b7
2 changed files with 13 additions and 28 deletions

View File

@@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
window.backgroundColor = UIColor.whiteColor()
window.rootViewController = ViewController(nibName: nil, bundle: nil)
window.rootViewController = ViewController()
window.makeKeyAndVisible()
self.window = window
return true

View File

@@ -12,55 +12,40 @@
import UIKit
import AsyncDisplayKit
class ViewController: UIViewController, ASTableViewDataSource, ASTableViewDelegate {
final class ViewController: ASViewController, ASTableDataSource, ASTableDelegate {
var tableView: ASTableView
var tableNode: ASTableNode {
return node as! ASTableNode
}
// MARK: UIViewController.
override required init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
self.tableView = ASTableView()
super.init(nibName: nil, bundle: nil)
self.tableView.asyncDataSource = self
self.tableView.asyncDelegate = self
init() {
super.init(node: ASTableNode())
tableNode.delegate = self
tableNode.dataSource = self
}
required init?(coder aDecoder: NSCoder) {
fatalError("storyboards are incompatible with truth and beauty")
}
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(self.tableView)
}
override func viewWillLayoutSubviews() {
self.tableView.frame = self.view.bounds
}
override func prefersStatusBarHidden() -> Bool {
return true
}
// MARK: ASTableView data source and delegate.
func tableView(tableView: ASTableView!, nodeForRowAtIndexPath indexPath: NSIndexPath!) -> ASCellNode! {
let patter = NSString(format: "[%ld.%ld] says hello!", indexPath.section, indexPath.row)
func tableView(tableView: ASTableView, nodeForRowAtIndexPath indexPath: NSIndexPath) -> ASCellNode {
let node = ASTextCellNode()
node.text = patter as String
node.text = String(format: "[%ld.%ld] says hello!", indexPath.section, indexPath.row)
return node
}
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 20
}