0
我剛開始在Xcode中使用swift3以利用Apple.inc提供的ResearchKit。 雖然我已經通過研究工具教程中的Swift教程:Ray Wenderlich入門,但我在ViewController的擴展中遇到了麻煩。以下是我的代碼。我得到了一個錯誤[類型「視圖控制器」不符合協議「ORKTaskViewControllerDelegate」]
import ResearchKit
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func consentTapped(sender : AnyObject) {
let taskViewController = ORKTaskViewController(task: ConsentTask, taskRun: nil)
taskViewController.delegate = self
present(taskViewController, animated: true, completion: nil)
}
}
extension ViewController: ORKTaskViewControllerDelegate {
func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason
reason: ORKTaskViewControllerFinishReason, error: NSError?) {
//Handle results with taskViewController.result
taskViewController.dismiss(animated:true, completion: nil)
}
}