ios - EXC_BAD_ACCESS in HealthKit in reading dateOfBirthWithError -


when call following function read dataofbirth, keep receiving bad access error while testing on device. i'm using swift 2.0 in xcode 7 beta

    func updateusersage(){      do{         var error : nserror!         let birthdate = try currenthealthstore.dateofbirthwitherror()          let = nsdate()          let datecomponents = nscalendar.currentcalendar().components(nscalendarunit.nsyearcalendarunit, fromdate: birthdate, todate: now, options: nscalendaroptions.wrapcomponents)         let age = datecomponents.year          self.agevaluelabel.text = nsnumberformatter.localizedstringfromnumber(nsnumber(integer: age), numberstyle: nsnumberformatterstyle.nostyle)      }     catch{          print("not avaialble")     } } 

currenthealthstore defined in appdelegate global variable:

let currenthealthstore = hkhealthstore() 

and error received once line executed:

let birthdate = try currenthealthstore.dateofbirthwitherror() 

this code works me in swift 2, xcode 7.1.1

let birthday = try healthstore.dateofbirth() 

the name dateofbirthwitherror has been used before error passed throws.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -