ios - Trying to save metadata - HealthKit -


i'm trying save data healthkit. sending uuid each item. it's nsuuid converted string.

hk_acceptsmetadatavalue:]: unrecognized selector sent

i don't i'm doing wrong. ideas?

    // save new item health app     func savesample(amount:double, date:nsdate, uuid: string ) {          // create metadata         let metadata : nsdictionary = [hkmetadatakeyexternaluuid : uuid]          // create sample         let unit = hkunit.literunitwithmetricprefix(.milli)         let type = hkquantitytype.quantitytypeforidentifier(hkquantitytypeidentifierdietarywater)         let quantity = hkquantity(unit: unit, doublevalue: amount)         let sample = hkquantitysample(type: type!, quantity: quantity,  startdate: date, enddate: date, metadata:metadata as! [string : anyobject])          // save sample in store         healthkitstore.saveobject(sample, withcompletion: { (success, error) -> void in             if( error != nil ) {                 print("error saving sample: \(error!.localizeddescription)")             } else {                 print("sample saved successfully!")             }         })     } 

because metadata should string xcode suggested add as! [string : anyobject] after variable metadata when create sample.

still got same error

you encountering known issue healthkit. can work around bug explicitly creating nsdictionary metadata instead of swift dictionary.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -