Compare commits

...

1 Commits

Author SHA1 Message Date
Gerardo Marx 05b30cf8e5 Survey Task example working 2 months ago

61
.gitignore vendored

@ -0,0 +1,61 @@
# Xcode specific
.DS_Store
*.xcuserstate
*.xcscmblueprint
*.swp
*.mode1v3
*.mode2v3
*.perspectivev3
# User-specific settings
xcuserdata/
*.xcworkspace/xcuserdata/
# Xcode build
build/
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
Pods/
Podfile.lock
# Carthage
Carthage/Build/
# Swift Package Manager
.build/
DerivedData/
SourcePackages/
Package.resolved
# Fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
# Generated files
*.moved-aside
*.hmap
*.ipa
*.xcuserdatad
*.localized
*.xcworkspacedata
# Temporary and System files
*.tmp
*.log
*.swp
*.lock
*.lock/
*.lck
*.sync
# Playgrounds
timeline.xctimeline
playground.xcworkspace
# SwiftPM
.swiftpm/

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "ResearchKit"]
path = ResearchKit
url = https://github.com/ResearchKit/ResearchKit.git

@ -13,8 +13,73 @@
7EE7BFA32CB8F25B0000161D /* Base in Resources */ = {isa = PBXBuildFile; fileRef = 7EE7BFA22CB8F25B0000161D /* Base */; }; 7EE7BFA32CB8F25B0000161D /* Base in Resources */ = {isa = PBXBuildFile; fileRef = 7EE7BFA22CB8F25B0000161D /* Base */; };
7EE7BFA52CB8F25C0000161D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7EE7BFA42CB8F25C0000161D /* Assets.xcassets */; }; 7EE7BFA52CB8F25C0000161D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7EE7BFA42CB8F25C0000161D /* Assets.xcassets */; };
7EE7BFA82CB8F25C0000161D /* Base in Resources */ = {isa = PBXBuildFile; fileRef = 7EE7BFA72CB8F25C0000161D /* Base */; }; 7EE7BFA82CB8F25C0000161D /* Base in Resources */ = {isa = PBXBuildFile; fileRef = 7EE7BFA72CB8F25C0000161D /* Base */; };
7EE7BFF62CB8FA1C0000161D /* SurveyTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EE7BFF52CB8FA1C0000161D /* SurveyTask.swift */; };
7EE7C01F2CB9E9D90000161D /* ResearchKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE7C0182CB9E60E0000161D /* ResearchKit.framework */; };
7EE7C0202CB9E9D90000161D /* ResearchKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE7C0182CB9E60E0000161D /* ResearchKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
7EE7C0212CB9E9D90000161D /* ResearchKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE7C01C2CB9E60E0000161D /* ResearchKitUI.framework */; };
7EE7C0222CB9E9D90000161D /* ResearchKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE7C01C2CB9E60E0000161D /* ResearchKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
7EE7C0172CB9E60E0000161D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = B183A5951A8535D100C76870;
remoteInfo = ResearchKit;
};
7EE7C0192CB9E60E0000161D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 86CC8E9A1AC09332001CCD89;
remoteInfo = ResearchKitTests;
};
7EE7C01B2CB9E60E0000161D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = CA1C7A5A288B0C68004DAB3A;
remoteInfo = "ResearchKitUI (iOS)";
};
7EE7C01D2CB9E60E0000161D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = CAD08967289DD747007B2A98;
remoteInfo = ResearchKitActiveTask;
};
7EE7C0232CB9EC410000161D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = B183A4731A8535D100C76870;
remoteInfo = ResearchKit;
};
7EE7C0252CB9EC410000161D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = CA1C7A40288B0C68004DAB3A;
remoteInfo = "ResearchKitUI (iOS)";
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
7EE7C0082CB8FF010000161D /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
7EE7C0222CB9E9D90000161D /* ResearchKitUI.framework in Embed Frameworks */,
7EE7C0202CB9E9D90000161D /* ResearchKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
7EE7BF982CB8F25B0000161D /* RK-Setup-Git.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RK-Setup-Git.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 7EE7BF982CB8F25B0000161D /* RK-Setup-Git.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RK-Setup-Git.app"; sourceTree = BUILT_PRODUCTS_DIR; };
7EE7BF9B2CB8F25B0000161D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 7EE7BF9B2CB8F25B0000161D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@ -24,6 +89,8 @@
7EE7BFA42CB8F25C0000161D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 7EE7BFA42CB8F25C0000161D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7EE7BFA72CB8F25C0000161D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 7EE7BFA72CB8F25C0000161D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7EE7BFA92CB8F25C0000161D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 7EE7BFA92CB8F25C0000161D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7EE7BFF52CB8FA1C0000161D /* SurveyTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyTask.swift; sourceTree = "<group>"; };
7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ResearchKit.xcodeproj; path = ResearchKit/ResearchKit.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -31,6 +98,8 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
7EE7C0212CB9E9D90000161D /* ResearchKitUI.framework in Frameworks */,
7EE7C01F2CB9E9D90000161D /* ResearchKit.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -40,8 +109,10 @@
7EE7BF8F2CB8F25B0000161D = { 7EE7BF8F2CB8F25B0000161D = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */,
7EE7BF9A2CB8F25B0000161D /* RK-Setup-Git */, 7EE7BF9A2CB8F25B0000161D /* RK-Setup-Git */,
7EE7BF992CB8F25B0000161D /* Products */, 7EE7BF992CB8F25B0000161D /* Products */,
7EE7BFBE2CB8F7520000161D /* Frameworks */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@ -63,10 +134,29 @@
7EE7BFA42CB8F25C0000161D /* Assets.xcassets */, 7EE7BFA42CB8F25C0000161D /* Assets.xcassets */,
7EE7BFA62CB8F25C0000161D /* LaunchScreen.storyboard */, 7EE7BFA62CB8F25C0000161D /* LaunchScreen.storyboard */,
7EE7BFA92CB8F25C0000161D /* Info.plist */, 7EE7BFA92CB8F25C0000161D /* Info.plist */,
7EE7BFF52CB8FA1C0000161D /* SurveyTask.swift */,
); );
path = "RK-Setup-Git"; path = "RK-Setup-Git";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
7EE7BFBE2CB8F7520000161D /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
7EE7C0112CB9E60E0000161D /* Products */ = {
isa = PBXGroup;
children = (
7EE7C0182CB9E60E0000161D /* ResearchKit.framework */,
7EE7C01A2CB9E60E0000161D /* ResearchKitTests.xctest */,
7EE7C01C2CB9E60E0000161D /* ResearchKitUI.framework */,
7EE7C01E2CB9E60E0000161D /* ResearchKitActiveTask.framework */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -77,10 +167,13 @@
7EE7BF942CB8F25B0000161D /* Sources */, 7EE7BF942CB8F25B0000161D /* Sources */,
7EE7BF952CB8F25B0000161D /* Frameworks */, 7EE7BF952CB8F25B0000161D /* Frameworks */,
7EE7BF962CB8F25B0000161D /* Resources */, 7EE7BF962CB8F25B0000161D /* Resources */,
7EE7C0082CB8FF010000161D /* Embed Frameworks */,
); );
buildRules = ( buildRules = (
); );
dependencies = ( dependencies = (
7EE7C0242CB9EC410000161D /* PBXTargetDependency */,
7EE7C0262CB9EC410000161D /* PBXTargetDependency */,
); );
name = "RK-Setup-Git"; name = "RK-Setup-Git";
productName = "RK-Setup-Git"; productName = "RK-Setup-Git";
@ -113,6 +206,12 @@
mainGroup = 7EE7BF8F2CB8F25B0000161D; mainGroup = 7EE7BF8F2CB8F25B0000161D;
productRefGroup = 7EE7BF992CB8F25B0000161D /* Products */; productRefGroup = 7EE7BF992CB8F25B0000161D /* Products */;
projectDirPath = ""; projectDirPath = "";
projectReferences = (
{
ProductGroup = 7EE7C0112CB9E60E0000161D /* Products */;
ProjectRef = 7EE7C0102CB9E60E0000161D /* ResearchKit.xcodeproj */;
},
);
projectRoot = ""; projectRoot = "";
targets = ( targets = (
7EE7BF972CB8F25B0000161D /* RK-Setup-Git */, 7EE7BF972CB8F25B0000161D /* RK-Setup-Git */,
@ -120,6 +219,37 @@
}; };
/* End PBXProject section */ /* End PBXProject section */
/* Begin PBXReferenceProxy section */
7EE7C0182CB9E60E0000161D /* ResearchKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ResearchKit.framework;
remoteRef = 7EE7C0172CB9E60E0000161D /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
7EE7C01A2CB9E60E0000161D /* ResearchKitTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = ResearchKitTests.xctest;
remoteRef = 7EE7C0192CB9E60E0000161D /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
7EE7C01C2CB9E60E0000161D /* ResearchKitUI.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ResearchKitUI.framework;
remoteRef = 7EE7C01B2CB9E60E0000161D /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
7EE7C01E2CB9E60E0000161D /* ResearchKitActiveTask.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ResearchKitActiveTask.framework;
remoteRef = 7EE7C01D2CB9E60E0000161D /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */ /* Begin PBXResourcesBuildPhase section */
7EE7BF962CB8F25B0000161D /* Resources */ = { 7EE7BF962CB8F25B0000161D /* Resources */ = {
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
@ -138,6 +268,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
7EE7BFF62CB8FA1C0000161D /* SurveyTask.swift in Sources */,
7EE7BFA02CB8F25B0000161D /* ViewController.swift in Sources */, 7EE7BFA02CB8F25B0000161D /* ViewController.swift in Sources */,
7EE7BF9C2CB8F25B0000161D /* AppDelegate.swift in Sources */, 7EE7BF9C2CB8F25B0000161D /* AppDelegate.swift in Sources */,
7EE7BF9E2CB8F25B0000161D /* SceneDelegate.swift in Sources */, 7EE7BF9E2CB8F25B0000161D /* SceneDelegate.swift in Sources */,
@ -146,6 +277,19 @@
}; };
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
7EE7C0242CB9EC410000161D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = ResearchKit;
targetProxy = 7EE7C0232CB9EC410000161D /* PBXContainerItemProxy */;
};
7EE7C0262CB9EC410000161D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "ResearchKitUI (iOS)";
targetProxy = 7EE7C0252CB9EC410000161D /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
7EE7BFA12CB8F25B0000161D /* Main.storyboard */ = { 7EE7BFA12CB8F25B0000161D /* Main.storyboard */ = {
isa = PBXVariantGroup; isa = PBXVariantGroup;
@ -203,7 +347,7 @@
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES; ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17; GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES; GCC_NO_COMMON_BLOCKS = YES;
@ -266,7 +410,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES; ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17; GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_NO_COMMON_BLOCKS = YES; GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

@ -7,7 +7,7 @@
<key>RK-Setup-Git.xcscheme_^#shared#^_</key> <key>RK-Setup-Git.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>0</integer> <integer>3</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>

@ -1,24 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--View Controller--> <!--View Controller-->
<scene sceneID="tne-QT-ifu"> <scene sceneID="tne-QT-ifu">
<objects> <objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController"> <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="RK_Setup_Git" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rr2-t4-Uvi">
<rect key="frame" x="87" y="706" width="218" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Button"/>
<connections>
<action selector="startSurveyTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="l4p-Pq-Qni"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view> </view>
<connections>
<outlet property="startTapped" destination="rr2-t4-Uvi" id="LDX-yP-Jiu"/>
</connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="93.89312977099236" y="3.5211267605633805"/>
</scene> </scene>
</scenes> </scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document> </document>

@ -0,0 +1,27 @@
//
// SurveyTask.swift
// RK-Setup-Git
//
// Created by Gerardo Marx Chávez Campos on 11/10/24.
//
import ResearchKit
struct SurveyTaskProvider {
static func createHeightFormTask() -> ORKOrderedTask {
let sectionHeaderFormItem = ORKFormItem(sectionTitle: "What's your height?")
let heightQuestionFormItem = ORKFormItem(identifier: "heightQuestionFormItem1", text: nil, answerFormat: ORKAnswerFormat.heightAnswerFormat())
heightQuestionFormItem.placeholder = "Tap here"
let formStep = ORKFormStep(identifier: "HeighQuestionIdentifier",
title: "Height info",
text: "Please answer the questions")
formStep.formItems = [sectionHeaderFormItem, heightQuestionFormItem]
return ORKOrderedTask(identifier: "Survey Task", steps: [formStep])
}
}

@ -6,14 +6,72 @@
// //
import UIKit import UIKit
import ResearchKit
import ResearchKitUI
class ViewController: UIViewController { class ViewController: UIViewController {
@IBOutlet weak var startTapped: UIButton!
@IBAction func startSurveyTapped(_ sender: Any) {
presentHeightSurvey()
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
startTapped.setTitle("Start Survey", for: .normal)
} }
func presentHeightSurvey() {
let taskViewController = ORKTaskViewController(task: SurveyTaskProvider.createHeightFormTask(), taskRun: nil)
taskViewController.delegate = self
present(taskViewController, animated: true, completion: nil)
}
} }
// Extesions can be in other file:
extension ViewController: ORKTaskViewControllerDelegate {
func taskViewController(_ taskViewController: ORKTaskViewController, didFinishWith reason: ORKTaskFinishReason, error: (any Error)?) {
// Handle the completion of the task and dismiss the view controller
taskViewController.dismiss(animated: true, completion: nil)
//handle error
guard reason == .completed else {
if let error = error {
print("The task was not completed: \(error.localizedDescription)")
}
return
}
// processing results:
if let results = taskViewController.result.results as? [ORKStepResult] {
processSurveyResults(results)
}
}
private func processSurveyResults(_ results: [ORKStepResult]) {
// here
for stepResults in results {
for result in stepResults.results! {
if let questionResult = result as? ORKQuestionResult {
print("Question ID: \(questionResult.identifier)")
processQuestionResult(questionResult)
}
}
}
}
private func processQuestionResult(_ result: ORKQuestionResult) {
if let heightResult = result as? ORKNumericQuestionResult, result.identifier == "heightQuestionFormItem1" {
if let heigth = heightResult.numericAnswer {
print("User's heigth is: \(heigth) cm")
}
}
}
}

@ -0,0 +1 @@
Subproject commit 57427e8c7e9c7c9e0186f99ebae22cfc6b5d51cb
Loading…
Cancel
Save