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
370
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
OSもどきOS
arkw
0
470
AIで効率化できた業務・日常
ochtum
0
120
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.3k
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
100
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
110
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
440
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
130
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
230
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
180
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
630
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
17
6.3k
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
530
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
GitHub's CSS Performance
jonrohan
1033
470k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
We Have a Design System, Now What?
morganepeng
55
8.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
A Soul's Torment
seathinner
6
2.9k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
The Mindset for Success: Future Career Progression
greggifford
PRO
0
360
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
170
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
330
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