Trying to implement the new menstrual flow object type in HealthKit, but getting an error when creating the sample. I coded it myself first, but it also fails with the code from WWDC 2015 session 203 video (about 11:24) below:
let dict = [HKMetadataKeyMenstrualCycleStart: true]
let type = HKCategoryType.categoryTypeForIdentifier(HKCategoryTypeIdentifierMenstrualFlow)!
let value = HKCategoryValueMenstrualFlow.Medium.rawValue
let date = NSDate()
let sample = HKCategorySample(type: type, value: value, startDate: date, endDate: date, metadata: dict)
This builds, but running results in the following on line 5 above:
+[_TtCSs29_NativeDictionaryStorageOwner000000011941B4B0 hk_acceptsMetadataValue:]: unrecognized selector sent to class 0x11941b4b0
Without the metadata dictionary, it complains at runtime that the specified key must be set in metadata. Either I'm missing something obvious and will have a big facepalm, or it'll likely be fixed in a beta++, but if anyone has better luck, please share.