Swift错误"使用未声明的类型"在ViewController中

时间:2018-06-06 16:28:17

标签: ios swift researchkit

我在Xcode上使用带有Swift的ResearchKit开发应用程序。 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)
    }
}

1 个答案:

答案 0 :(得分:1)

尝试在您调用import ResearchKit相关内容的视图控制器中添加ResearchKit

import UIKit
import ResearchKit