classprotocolsswift3xcode8watchos-3

Want to create a custom class XY that inherits from a Class and a Protocol


I want to create the AVAudioInputNode in watchOS 3.

If I click on JumpToDefinition for AVAudioInputNode, I see that:

open class AVAudioInputNode : AVAudioIONode, AVAudioMixing {
}

Why I can't create a custom class with the same style ?

My class is:

open class xy : AVAudioIONode, AVAudioMixing {
}

The error is

Type xy does not conform to protocol "AvAudioMixing" and "AVAudioStereoMixing"


Solution

  • That means you need to conform to those 2 protocols, that means you need to apply specific functions or properties that those protocols requiere.

    For Example, for table views on a UIViewController Class you use 2 protocols: UITablewViewDelegate, UITableViewDataSource. And to conform those protocols you need to use this functions.

    func tableView(_ tableView: UITableView, numberOfRowsInSection: Int) -> int {
    return 1 
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
      let cell = tablewView.dequehueReusableCell(withIdentifier: "weatherCell", for: indexPath)
      return cell
    }
    

    And also assign its delegate and Data source:

    tableView.delegate = self
    tableView.dataSource = self
    

    In the specific case of those 2 protocols AVAudioIONode, AVAudioMixing you should search which are the required functions you need to conform.