![](/img/trans.png)
[英]Argument type 'Int' does not conform to expected type 'NSCoding & NSCopying & NSObjectProtocol'
[英]I got an error [Type “View Controller” does not conform to protocol “ORKTaskViewControllerDelegate”]
我剛剛開始在Xcode中使用swift3,以便利用Apple.inc提供的ResearchKit。 盡管我已經研究了Swift的Researchkit Tutorial中的教程:Ray Wenderlich入門,但在ViewController擴展方面還是遇到了麻煩。 以下是我的代碼。
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)
}
}
您錯過了添加委托。 將ORKTaskViewControllerDelegate
添加到ViewController
class ViewController: UIViewController,ORKTaskViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad(
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.