Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Getting step count on iOS
Search
sato-shin
March 27, 2019
Programming
3.3k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Getting step count on iOS
iOSで正しく歩数を取得する方法を説明します。
sato-shin
March 27, 2019
More Decks by sato-shin
See All by sato-shin
Goビルドを理解し、 CI/CDの高速化に挑む
satoshin
0
430
DateComponentsと仲良くなる
satoshin
3
3.8k
Bitriseのビルド回数が 10倍以上になって変わったコト
satoshin
1
480
Pull Request Trigger について ~Expose for Pull Request?~
satoshin
1
160
User Notification for UX!
satoshin
0
190
Using various views on Notification Content app extension
satoshin
2
1.2k
Other Decks in Programming
See All in Programming
1B+ /day規模のログを管理する技術
broadleaf
0
130
OS アップデート対応の取り組み方がもっと共有されてほしい
andpad
0
110
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
360
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.3k
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
120
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
240
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
290
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
830
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
340
Webフレームワークの ベンチマークについて
yusukebe
0
200
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
130
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
400
Featured
See All Featured
Claude Code のすすめ
schroneko
67
230k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
800
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
310
Navigating Team Friction
lara
192
16k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
340
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
370
Transcript
J04Ͱਖ਼͘͠าΛऔಘ͢Δ TBUPTIJO!8*5$P-UE
৯ࣄهΞϓϦʮ͚͋͢Μʯ ࣌ ສਓ͕ར༻͢Δ ৯ࣄهʹಛԽͨ͠ lϔϧεέΞzΞϓϦ
৯ࣄهΞϓϦʮ͚͋͢Μʯ ࣌ ສਓ͕ར༻͢Δ ৯ࣄهʹಛԽͨ͠ lϔϧεέΞzΞϓϦ าॏཁͳࢦඪͷҰͭ
าʹର͢Δಈػ͚ ! ফඅΧϩϦʔͷՄࢹԽ ϙΠϯτ ϙέϞϯ ͓ۚ
J04ʹ͓͚Δาͷऔಘํ๏ w$.1FEPNFUFSΛར༻ w)FBMUI,JUΛར༻
J04ʹ͓͚Δาͷऔಘํ๏ w$.1FEPNFUFSΛར༻ w)FBMUI,JUΛར༻
$.1FEPNFUFSΛར༻͢Δ w TUBSUdFOE·ͰͷؒͰͰݕͨ͠าΛऔಘ ‣ "QQMF8BUDIͷใऔಘ8BUDI"QQͰ࣮ w औಘͰ͖Δͷաڈ let pedometer =
CMPedometer() pedometer.queryPedometerData(from: start, to: end) { (data, error) in print(data?.numberOfSteps) }
J04ʹ͓͚Δาͷऔಘํ๏ .FUIPEPGHFUUJOHTUFQDPVOUPOJ04 w$.1FEPNFUFSΛར༻ w)FBMUI,JUΛར༻
ʮ͍ͭʯɺʮԿาʯ͕֨ೲ )FBMUI,JUΛར༻͢Δ b)FBMUI`BQQาͯ͢ͷσʔλΛදࣔ
let store = HKHealthStore() let type = HKSampleType.quantityType(forIdentifier: .stepCount)! let
predicate = HKQuery.predicateForSamples(withStart: start, end: end) let query = HKSampleQuery(sampleType: type, predicate: predicate, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { (query, result, error) in let result = result as! [HKQuantitySample] let sum = result(0) { $0 + $1.quantity.doubleValue(for: .count()) } print(sum) } store.execute(query) )FBMUI,JUΛར༻͢Δ
let store = HKHealthStore() let type = HKSampleType.quantityType(forIdentifier: .stepCount)! let
predicate = HKQuery.predicateForSamples(withStart: start, end: end) let query = HKSampleQuery(sampleType: type, predicate: predicate, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { (query, result, error) in let result = result as! [HKQuantitySample] let sum = result(0) { $0 + $1.quantity.doubleValue(for: .count()) } print(sum) } store.execute(query) )FBMUI,JUΛར༻͢Δ าΛ ظؒͰ શͯऔಘ ΫΤϦ࣮ߦ DPNQMFUJPOIBOEMFS
let store = HKHealthStore() let type = HKSampleType.quantityType(forIdentifier: .stepCount)! let
predicate = HKQuery.predicateForSamples(withStart: start, end: end) let query = HKSampleQuery(sampleType: type, predicate: predicate, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { (query, result, error) in let result = result as! [HKQuantitySample] let sum = result(0) { $0 + $1.quantity.doubleValue(for: .count()) } print(sum) } store.execute(query) )FBMUI,JUΛར༻͢Δ
J1IPOF͔Βͷσʔλ "QQMF8BUDI͔Βͷσʔλ )FBMUI,JUΛར༻͢Δ ⚠ॏෳͯ͠Χϯτ͞ΕΔ J1IPOF͚ͩͰςετ͢Δͱɺ ্ख͍ͬͯͦ͘͏ʹݟ͑ΔͷͰҙ
let store = HKHealthStore() let type = HKSampleType.quantityType(forIdentifier: .stepCount)! let
predicate = HKQuery.predicateForSamples(withStart: start, end: end) let query = HKSampleQuery(sampleType: type, predicate: predicate, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { (query, result, error) in let result = result as! [HKQuantitySample] let sum = result(0) { $0 + $1.quantity.doubleValue(for: .count()) } print(sum) } store.execute(query) )FBMUI,JUΛར༻͢Δ
let store = HKHealthStore() let type = HKSampleType.quantityType(forIdentifier: .stepCount)! let
predicate = HKQuery.predicateForSamples(withStart: start, end: end) let query = HKSampleQuery(sampleType: type, predicate: predicate, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { (query, result, error) in let result = result as! [HKQuantitySample] let sum = result(0) { $0 + $1.quantity.doubleValue(for: .count()) } print(sum) } store.execute(query) )FBMUI,JUΛར༻͢Δ HKSampleQuery ɹ݅ʹϚον͢Δ ɹݸʑͷΛऔಘ͢Δ
let store = HKHealthStore() let type = HKSampleType.quantityType(forIdentifier: .stepCount)! let
predicate = HKQuery.predicateForSamples(withStart: start, end: end) let query = HKSampleQuery(sampleType: type, predicate: predicate, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { (query, result, error) in let result = result as! [HKQuantitySample] let sum = result(0) { $0 + $1.quantity.doubleValue(for: .count()) } print(sum) } store.execute(query) )FBMUI,JUΛར༻͢Δ HKSampleQuery ɹ݅ʹϚον͢Δ ɹݸʑͷΛऔಘ͢Δ ɹݸʑͷͰͳ͘ɺ ɹσʔλͷಛ͕Γ͍ͨ
ݸʑͷΛऔಘ͍ͨ͠ HKSampleQuery άϧʔϓͷಛΛऔಘ͍ͨ͠(sum,ave,min,max,latest) ɹ HKStatisticsQuery / HKStatisticsCollectionQuery )FBMUI,JUΛར༻͢Δ
let store = HKHealthStore() let type = HKSampleType.quantityType(forIdentifier: .stepCount)! let
predicate = HKQuery.predicateForSamples(withStart: start, end: end) let query = HKStatisticsQuery(quantityType: type, quantitySamplePredicate: predicate, options: .cumulativeSum) { (query, statistics, error) in print(statistics?.sumQuantity()) } store.execute(query) )FBMUI,JUΛར༻͢Δ ྦྷੵ ॏෳʹର͍͍ͯ͠ײ͡ʹܭࢉͯ͘͠ΕΔ☺
ෆਖ਼ରࡦ )FBMUI,JUΛར༻͢Δ J1IPOFͱ"QQMF8BUDIͷาܭσʔλͷΈΛൈ͖ग़͢ !
)FBMUI,JUΛར༻͢Δ
)FBMUI,JUΛར༻͢Δ खಈͰՃͰ͖Δ
)FBMUI,JUΛར༻͢Δ )FBMUI"QQDPNBQQMF)FBMUI J1IPOFDPNBQQMFIFBMUI<66*%> ֤߲ॻ͖ࠐΜͩΞϓϦͷ #VOEMF*EFOUJpFSͷใΛ࣋ͭ IBT1SFpY lDPNBQQMFIFBMUIz ͰϑΟϧλʔ͢Ε0, "QQMF8BUDIDPNBQQMFIFBMUI<66*%>
4BNQMFDPEF https://github.com/sato-shin/ios-steps
None