I'm following a ResearchKit tutorial in swift (http://www.raywenderlich.com/104575/researchkit-tutorial-with-swift) and I can't connect either of my IBaction methods to buttons in the main storyboard. Here's the code (from the tutorial):
import ResearchKit
class ViewController: UIViewController {
@IBAction func consentTapped(sender : AnyObject) {
let taskViewController = ORKTaskViewController(task: ConsentTask, taskRunUUID: nil)
taskViewController.delegate = self
presentViewController(taskViewController, animated: true, completion: nil)
}
@IBAction func surveyTapped(sender : AnyObject) {
let taskViewController = ORKTaskViewController(task: SurveyTask, taskRunUUID: nil)
taskViewController.delegate = self
presentViewController(taskViewController, animated: true, completion: nil)
}
}
extension ViewController : ORKTaskViewControllerDelegate {
func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
taskViewController.dismissViewControllerAnimated(true, completion: nil)
}
}
I go into the main storyboard and click on the View Controller, and I've tried setting my class both to ViewController and UIViewController, and the methods are supposed to show up in Sent Events, but they don't. I've also tried ctrl dragging, and that hasn't worked for me either.
You can change the
@IBAction
's argument from(_ sender: Any)
to(_ sender: AnyObject)
, but manually. And try to use Ctrl+Drag, please.It might work.