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
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
Oxcを導入して開発体験が向上した話
yug1224
4
320
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
250
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.4k
ふつうのFeature Flag実践入門
irof
8
4.1k
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.3k
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.3k
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
590
dRuby over BLE
makicamel
2
380
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
140
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
890
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
260
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
290
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Navigating Weather and Climate Data
rabernat
0
220
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
750
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
600
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
Exploring anti-patterns in Rails
aemeredith
3
420
AI: The stuff that nobody shows you
jnunemaker
PRO
8
720
Color Theory Basics | Prateek | Gurzu
gurzu
0
370
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
Designing Experiences People Love
moore
143
24k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
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