Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HealthKitをSwift4でいじってみた

 HealthKitをSwift4でいじってみた

第77回Cocoa勉強会関西

Beba158ac4c0f2aa7fa2ee15b2ae4ff3?s=128

studioshin

April 21, 2018
Tweet

Transcript

  1. HealthKitΛ Swift4Ͱ͍ͬͯ͡Έͨ ୈ77ճ Cocoaษڧձؔ੢ 2018೥4݄14೔ @studioshin

  2. ࣗݾ঺հ ϑϦʔͰiOS/MacΞϓϦ։ൃ΍ͬͯ·͢ ๺ଜ ਅೋ STUDIO SHIN @studioshin Twitter: Cocoaษڧձؔ੢ɹ୅ද

  3. ͜ΜͳຊΛॻ͍ͯ·͢ɻ

  4. )FBMUI,JUͱ͸ʁ J04͔Β௥Ճ͞Εͨɺ݈߁ؔ࿈ͷσʔλΛ औΓѻ͏ϑϨʔϜϫʔΫɻ ʰϔϧεέΞʱΞϓϦΛத৺ʹɺϢʔβʔͷ ਎௕ɺମॏɺา਺ɺΞΫςϏςΟɺফඅΧϩ ϦʔͳͲΛऔΓ·ͱΊΔσʔλϕʔεɻ σʔλʹ͸αʔυύʔςΟΞϓϦ͔Β΋ΞΫ ηεՄೳɻʢରԠΞϓϦʹ͸ϓϥΠόγʔϙ Ϧγʔͷද͕ࣔٛ຿෇͚ΒΕΔʣ

  5. )FBMUI,JU΍ͬͯΈΑ͏ͱࢥͬͨཧ༝ ࢓ࣄͰ)FBMUI,JUରԠΞϓϦΛ࡞Δ͜ͱʹͳͬͨɻ ࣌ؒͳ͔ͬͨͷͰɺӳޠͷυΩϡϝϯτಡΈ ࠐ·ͳ͍Ͱ೔ຊޠهࣄΛάάͬͯΈͨɻ ৽نΞϓϦͳͷͰɺ౰વJ04 9DPEF 4XJGUͰ࡞Δɻ ৽͍͠Ϋϥε΍ܕ͕ΊͬͪΌଟ͍ͧʂʁ ?@? ղઆهࣄ͸J04ͱ͔4XJGU͕ଟ͍ʂ

  6. IUUQTEFWDMBTTNFUIPEKQSFGFSFODFTJPTIFBMUILJUBQQ ओʹࢀߟʹͤͯ͞௖͍ͨهࣄ͸ͪ͜Βɻ

  7. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU )FBMUI,JUͷσʔλ͕ཉ͍͠ʂ

  8. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU ),)FBMUI4UPSF )FBMUI,JU͞·ʹ͸ɺ Θ͠Λ௨ͯ͠࿩Λ͢Δͷ͡Όʂ ྑ͖ʹ͸͔Β͑

  9. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU ),)FBMUI4UPSF ॻ͖ࠐΈ ಡΈࠐΈ σʔλΛ ಡΈࠐΈ͍ͨʂ ॻ͖ࠐΈ͍ͨʂ

  10. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU ),)FBMUI4UPSF ॻ͖ࠐΈ ಡΈࠐΈ Ϣʔβʔ༷ɺ ͍͔͕͍ͨ͠·͔͢ʁ Ϣʔβʔ

  11. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU ),)FBMUI4UPSF ॻ͖ࠐΈ ಡΈࠐΈ Ϣʔβʔ ڐՄ ! ͍͍Αʂ

  12. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU ॻ͖ࠐΈ ಡΈࠐΈ ),)FBMUI4UPSF

  13. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU ॻ͖ࠐΈ ಡΈࠐΈ ),)FBMUI4UPSF ),2VFSZ ),4BNQMF

  14. )FBMUI,JUͷ֓ཁ "QQ )FBMUI,JU ॻ͖ࠐΈ ಡΈࠐΈ ),)FBMUI4UPSF ),0CKFDU ),0CKFDU ඇಉظ

  15. )FBMUI,JUͰѻ͑Δओͳσʔλ ˙Ϣʔβʔͷ਎ମσʔλ )FBMUI,JUͷ֓ཁ ˙ଌఆσʔλ ˙ΧςΰϦʔσʔλ ݂ӷܕɺੜ೥݄೔ɺੑผɺഽɺंҜࢠ࢖༻ ਎௕ɺମॏɺา਺ɺ݂ѹɺͳͲʜ ਭ຾ɺελϯυ࣌ؒɺੑߦҝɹͳͲʜ

  16. ),)FBMUI4UPSF )FBMUI,JUͷอޢྖҬ΁ͷΞΫηεΛ஥հ͢ ΔΫϥεɻ σʔλΞΫηεͷڐՄɺಡΈॻ͖͸͸͜ͷ ΫϥεΛ௨ͯ͡ߦ͏ɻ )FBMUI,JUͷ֓ཁ

  17. ),0CKFDU )FBMUI,JUͱσʔλΛ΍ΓऔΓ͢ΔͨΊͷΫ ϥεɻ ಡΈॻ͖ʹԠ͍͔ͯͭ͘͡ͷαϒΫϥε͕ ͋ΓɺͦͷαϒΫϥεΛ௨ͯ͡)FBMUI,JUͱ σʔλΛ΍ΓऔΓ͢Δɻ )FBMUI,JUͷ֓ཁ

  18. ),0CKFDUͷαϒΫϥε )FBMUI,JU͔ΒσʔλΛಡΈࠐΉࡍʹ࢖༻͢ ΔΫϥεɻσʔλͷछྨʹԠ͍͔ͯͭ͘͡ ͷαϒΫϥε͕͋Δɻ )FBMUI,JUͷ֓ཁ ),2VFSZ

  19. ),0CKFDUͷαϒΫϥε ),)FBMUI4UPSFʹσʔλΛ໰͍߹ΘͤΔΫϥεɻ )FBMUI,JUͷ֓ཁ ),2VFSZͷओͳαϒΫϥε ),4BNQMF2VFSZ ),4UBUJTUJDT2VFSZ ౷ܭσʔλΛऔಘ͢ΔͨΊͷΫϥεɻ ),4UBUJTUJDT$PMMFDUJPO2VFSZ ࿈ଓͨ͠౷ܭσʔλΛऔಘ͢ΔͨΊͷΫϥεɻ

  20. ),0CKFDUͷαϒΫϥε )FBMUI,JUʹσʔλΛॻ͖ࠐΉࡍʹ࡞੒͢Δ ΫϥεɻσʔλͷछྨʹԠ͍͔ͯͭ͘͡ͷ αϒΫϥε͕͋Δɻ )FBMUI,JUͷ֓ཁ ),4BNQMF

  21. ),0CKFDUͷαϒΫϥε ྔ΍਺஋Ͱද͞ΕΔσʔλΛѻ͏ɻ )FBMUI,JUͷ֓ཁ ),4BNQMFͷओͳαϒΫϥε ),2VBOUJUZ4BNQMF ),$BUFHPSZ4BNQMF ΧςΰϦʔͰද͞ΕΔσʔλΛѻ͏ɻ

  22. ),6OJU ୯ҐΛද͢Ϋϥεɻ ηϯνϝʔτϧɺάϥϜɺΧϩϦʔɹͳͲʜ )FBMUI,JUͷ֓ཁ ),0CKFDU5ZQF σʔλͷछྨΛද͢Ϋϥεɻ ਎௕ɺମॏɺڑ཭ɺา਺ɹͳͲʜ ͜ΕΒͷΫϥεɺαϒΫϥεͰѻ͏σʔλΛ ಛఆ͢Δɻ

  23. )FBMUI,JUରԠΞϓϦͷ࡞Γํ "QQ*%༗ޮαʔϏεͰ)FBMUI,JUʹνΣοΫΛೖΕΔɻ

  24. )FBMUI,JUରԠΞϓϦͷ࡞Γํ $BQBCJMJUJFTͰ)FBMUI,JUΛ0/ʹ͢Δɻ શͯʹνΣοΫ͕෇͘ ͷΛ֬ೝʂ

  25. )FBMUI,JUରԠΞϓϦͷ࡞Γํ ιʔείʔυʹ)FBMUI,JUΛΠϯϙʔτ͢Δɻ import UIKit import HealthKit class ViewController: UIViewController {

    override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
  26. )FBMUI,JUରԠΞϓϦͷ࡞Γํ *OGPQMJTUʹ)FBMUI,JUͷΩʔΛ௥ه͢Δɻ LFZ/4)FBMUI4IBSF6TBHF%FTDSJQUJPOLFZTUSJOH6TF)FBMUI,JUTUSJOH LFZ/4)FBMUI6QEBUF6TBHF%FTDSJQUJPOLFZTUSJOH6TF)FBMUI,JUTUSJOH

  27. ͜ΕͰجຊతͳ ४උ͸׬ྃʂ