ORKDataCollectionManager Class Reference
Inherits from | NSObject |
---|---|
Declared in | ORKDataCollectionManager.h |
The data collection manager is used to collect HealthKit data and CoreMotion data.
It uses collectors to track data types to be collected. Anchors are used to track progress of each types of data to avoid duplications. Collected data samples are returned in the delegation methods, return YES to confirm the samples has been accepted.
– initWithPersistenceDirectoryURL:
Initiate the manager with a persistence directory. The directory is used to store the configurations and progress of the collectors.
- (instancetype)initWithPersistenceDirectoryURL:(NSURL *)directoryURL
Parameters
directoryURL |
URL path for the directory. |
---|
Return Value
Initiated ORKDataCollectionManager instance.
Declared In
ORKDataCollectionManager.h
collectors
An array of collectors.
@property (copy, readonly) NSArray<ORKCollector*> *collectors
Declared In
ORKDataCollectionManager.h
delegate
Implement the delegate to receive collected data objects.
@property (nonatomic, weak, nullable) id<ORKDataCollectionManagerDelegate> delegate
Declared In
ORKDataCollectionManager.h
– addHealthCollectorWithSampleType:unit:startDate:error:
Add a collector for HealthKit quantity and category samples.
- (ORKHealthCollector *)addHealthCollectorWithSampleType:(HKSampleType *)sampleType unit:(HKUnit *)unit startDate:(NSDate *)startDate error:(NSError *_Nullable *)error
Parameters
sampleType |
HealthKit sample type. |
---|---|
unit |
HealthKit unit into which data should be collected. |
startDate |
Samples should be collected starting at this date. |
error |
Any error detected during this operation. |
Return Value
Initiated health collector.
Declared In
ORKDataCollectionManager.h
– addHealthCorrelationCollectorWithCorrelationType:sampleTypes:units:startDate:error:
Add a collector for HealthKit correlations.
- (ORKHealthCorrelationCollector *)addHealthCorrelationCollectorWithCorrelationType:(HKCorrelationType *)correlationType sampleTypes:(NSArray<HKSampleType*> *)sampleTypes units:(NSArray<HKUnit*> *)units startDate:(NSDate *)startDate error:(NSError *_Nullable *)error
Parameters
correlationType |
HealthKit correlation type. |
---|---|
sampleTypes |
Array of HKSampleType expected in the correlation. |
units |
Array of HKUnit to use when serializing the samples collected (should be same size as sampleTypes). |
startDate |
Samples should be collected starting at this date. |
error |
Any error detected during this operation. |
Return Value
Initiated health correlation collector.
Declared In
ORKDataCollectionManager.h
– addMotionActivityCollectorWithStartDate:error:
Add a collector for motion activity.
- (ORKMotionActivityCollector *)addMotionActivityCollectorWithStartDate:(NSDate *)startDate error:(NSError *_Nullable *)error
Parameters
startDate |
When data collection should start. |
---|---|
error |
Error during this operation. |
Return Value
Initiated motion activity collector.
Declared In
ORKDataCollectionManager.h
– removeCollector:error:
Remove a collector.
- (BOOL)removeCollector:(ORKCollector *)collector error:(NSError *_Nullable *)error
Parameters
collector |
The collector to be removed. |
---|---|
error |
Error during this operation. |
Return Value
If this operation is successful.
Declared In
ORKDataCollectionManager.h
– startCollection
Start data collection.
This method triggers running all the RKCollector collections associated with the present manager.
When the collection is completed, delegate recieves a method call dataCollectionManagerDidCompleteCollection:
.
- (void)startCollection
Declared In
ORKDataCollectionManager.h