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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
380
DateComponentsと仲良くなる
satoshin
3
3.7k
Bitriseのビルド回数が 10倍以上になって変わったコト
satoshin
1
470
Pull Request Trigger について ~Expose for Pull Request?~
satoshin
1
150
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
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
130
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
260
スマートグラスで並列バイブコーディング
hyshu
0
140
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
7
4.4k
Webフレームワークの ベンチマークについて
yusukebe
0
170
Contextとはなにか
chiroruxx
1
320
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
3.9k
The NotImplementedError Problem in Ruby
koic
1
780
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
130
Lessons from Spec-Driven Development
simas
PRO
0
190
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
480
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Context Engineering - Making Every Token Count
addyosmani
9
960
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
AI: The stuff that nobody shows you
jnunemaker
PRO
8
710
For a Future-Friendly Web
brad_frost
183
10k
First, design no harm
axbom
PRO
2
1.2k
Scaling GitHub
holman
464
140k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
Building Applications with DynamoDB
mza
96
7.1k
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