0

trying to use AsyncdisplayKit for the 1st time in swift 3.

There is something that i do not understand :

i simply set up my ASviewController :

   final class NodeFeedViewController: ASViewController<ASDisplayNode>, ASTableDataSource, ASTableDelegate {

var tableNode: ASTableNode {
    return node as! ASTableNode
}

init() {
    super.init(node: ASTableNode())
    self.node.view.backgroundColor = UIColor.purple
    self.node.backgroundColor = UIColor.yellow
    self.tableNode.delegate = self
    self.tableNode.dataSource = self
}
required init?(coder aDecoder: NSCoder) {
    fatalError("storyboards are incompatible with truth and beauty")
}

Then i set up my ASTableNode :

func tableNode(tableNode: ASTableNode, nodeForRowAtIndexPath indexPath: NSIndexPath) -> ASCellNode {

    let rowCount = 15

    let node = ASTextCellNode()
    node.text = String(format: "[%ld.%ld] says hello!", indexPath.section, indexPath.row)

    return node
}

func numberOfSectionsInTableNode(tableNode: ASTableNode) -> Int {
    return 1
}

func tableNode(tableNode: ASTableNode, numberOfRowsInSection section: Int) -> Int {
    var count = 16
    return count
}

Problem is that i compile because Xcode tells me that my controller does not conform to protocol 'ASCommon TableViewDataSource', the only way to make it work is to add the native :

/*
@available(iOS 2.0, *)
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}*

/

Any idea why it is not working on my project and that it's work on the swift example projet of AsyncdisplayKit ? Thanks for any help.

user2206906
  • 1,310
  • 2
  • 13
  • 18

1 Answers1

0

First: you need put your ViewController() in AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let window = UIWindow(frame: UIScreen.main.bounds)
    window.backgroundColor = UIColor.white
    window.rootViewController = UINavigationController(rootViewController: ViewController());
    window.makeKeyAndVisible()
    self.window = window
    return true
}

*ViewController() is the name of your controller that contains the table.

Second: check if your MainStoryboard don't have the viewcontroller associated, if it is, only clear that field.

Third: Don't forget to install the pod in your project.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Daniel Carreto
  • 211
  • 1
  • 9