我正在开发一个在 Xcode 上使用 ResearchKit 和 Swift 的应用程序。ResearchKit 软件相对简单,但视图控制器中的这段特定代码有以下信息:
“使用未声明的类型”
对于所有三种ORKTaskViewControllerXXX
类型,我不知道如何解决它。这是我的代码:
import UIKit
class ViewController: UIViewController {
@IBAction func consentTapped(sender : AnyObject) {
let ORKTaskViewController = taskViewController(task: consentTapped, taskRunUUID: nil)
taskViewController.delegate = self
presentViewController(taskViewController, animated: true, completion: nil)
}
}
extension ViewController : ORKTaskViewControllerDelegate {
func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
//Handle results with taskViewController.result
taskViewController.dismissViewControllerAnimated(true, completion: nil)
}
}