swift2 - swift 2.0 healthkit requestAuthorizationToShareTypes - Type of expression is ambiguous without more context -


after converting swift 1.2 2.0 following error: type of expression ambiguous without more context when request authorisation follow:

healthkitstore.requestauthorizationtosharetypes(writetypes: healthkittypestowrite, readtypes: healthkittypestoread,completion:  { success, error in         if success {             print("success")         } else {             print(error.description)         }         }) 

any ideas?

i fixed problem, , not sure has error message itself.

1) healthkittypestoread , write: removed [ ] set ( [ ] )

2) created new completion duple

3) changed call follow bellow

example:

let healthkittypestoread = set(         arrayliteral: hkobjecttype.characteristictypeforidentifier(hkcharacteristictypeidentifierdateofbirth)!,         hkobjecttype.characteristictypeforidentifier(hkcharacteristictypeidentifierbiologicalsex)!,         hkobjecttype.workouttype()         )  let newcompletion: ((bool, nserror?) -> void) = {         (success, error) -> void in          if !success {             print("you didn't allow healthkit access these write data types.\nthe error was:\n \(error!.description).")              return         }     }   healthkitstore.requestauthorizationtosharetypes(healthkittypestowrite, readtypes: healthkittypestoread, completion: newcompletion) 

now code compiles properly


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -