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
390
DateComponentsと仲良くなる
satoshin
3
3.7k
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
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
140
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
14
5.6k
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
110
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
7k
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
150
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
110
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
270
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
150
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
Designing for humans not robots
tammielis
254
26k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
600
Optimising Largest Contentful Paint
csswizardry
37
3.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
4 Signs Your Business is Dying
shpigford
187
22k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
490
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
210
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
270
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
430
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