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
[#2 Swift Meetup SP - 2017] Heurísticas e Swift: Do “NSProcessInfo” à um shake no Apple Watch
Search
Ezequiel Santos
May 17, 2017
Technology
0
200
[#2 Swift Meetup SP - 2017] Heurísticas e Swift: Do “NSProcessInfo” à um shake no Apple Watch
#2 Swift Meetup SP
https://github.com/ezefranca/WatchShaker
Ezequiel Santos
May 17, 2017
Tweet
Share
More Decks by Ezequiel Santos
See All by Ezequiel Santos
Dependency Management in iOS Development: A Developer Survey Perspective
ezefranca
0
8
Mestrado: Gestos e jogos: reflexões e desenvolvimento de um sistema de detecção de gestos baseado em wearables para controle de jogos
ezefranca
0
250
Server-Driven UI na prática
ezefranca
0
260
Modelo Clássico e Jogos (Jesper Jull) e exergames.
ezefranca
0
91
Server Driven UI Diferença e evolução em 2010 e 2020
ezefranca
0
1.3k
[#2 Community day Shawee] Prototipação eletrônica em Hackathons: idéias makers ganhando vida
ezefranca
0
910
[7 Masters - Intercon 2018] 7 dicas de performance Mobile
ezefranca
0
260
[TDC Florianopolis 2018] - 5 Soft Skills para desenvolvedores iOS
ezefranca
0
730
[7 Masters] Wearables - WatchShaker
ezefranca
1
280
Other Decks in Technology
See All in Technology
Taking Flight with Tailwind CSS
opdavies
0
4.3k
本当のガバクラ基礎
toru_kubota
0
320
Databricksの生成AI戦略
taka_aki
1
370
RubyKaigi 2024 - Make Your Own Regex Engine!
makenowjust
0
150
スクラムに出会って「できた」を実感できるようになってきた話 / Scrum makes me feel like I can do it
yayoi_dd
2
110
5分で分かる(かもしれない) Vector engine for OpenSearch Serverless
tsukuboshi
1
400
個人的、Kubernetes の最新注目機能! (2024年5月版) / TechFeed Experts Night#28 〜 コンテナ技術最前線
pfn
PRO
3
210
Step by Stepで学ぶ、ADT(代数的データ型)、モナドからEffect-TSまで
leveragestech
1
3k
パフォーマンス最適化のベストプラクティス
databricksjapan
0
200
シンプルなHITL機械学習と様々なタスクにおけるHITL機械学習
naohachi89
0
320
TiDBにおけるテーブル設計と最適化の事例
cygames
0
790
.NET GraphQL Client のリアル
sansantech
PRO
1
250
Featured
See All Featured
The Cult of Friendly URLs
andyhume
74
5.7k
Designing Experiences People Love
moore
136
23k
Documentation Writing (for coders)
carmenintech
60
4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
9
1.3k
How to Ace a Technical Interview
jacobian
273
22k
Bash Introduction
62gerente
605
210k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
12
1.1k
Teambox: Starting and Learning
jrom
128
8.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
242
1.2M
Product Roadmaps are Hard
iamctodd
45
9.8k
Unsuck your backbone
ammeep
664
57k
What’s in a name? Adding method to the madness
productmarketing
PRO
17
2.7k
Transcript
Swift Meetup SP Heurísticas e Swift: Do “NSProcessInfo” a um
shake no Apple Watch Ezequiel França
Mecatrônica @ SENAI Automação Industrial @ IFSP Analise de Sistemas
@ FIAP Desenvolvedor iOS, Maker e open-source hacker. Ezequiel França
https://www.youtube.com/watch?v=BoeRfMBVCGo
None
Swift Meetup SP ❤
Heurísticas?
None
None
None
None
None
None
None
http://mathwiki.cs.ut.ee/asymptotics/05_polynomial_complexity
Let’s Shake
None
None
http://indiatoday.intoday.in/technology/story/apple-watch- handshakes-nfc-gestures/1/448093.html
None
lembrando rapidinho de protocolos delegates
protocol SomeProtocol { func someTypeMethod() }
protocol SomeProtocol { func someTypeMethod() } class SomeClass: SomeProtocol{ }
protocol WatchShakerDelegate { func watchShakerDidShake(_ watchShaker: WatchShaker) func watchShaker(_ watchShaker:WatchShaker,
didFailWith error: Error) }
protocol WatchShakerDelegate { func didShake() func didFail(error: Error) }
protocol WatchShakerDelegate { func watchShakerDidShake(_ watchShaker: WatchShaker) func watchShaker(_ watchShaker:WatchShaker,
didFailWith error: Error) }
class WatchShaker { public var delegate: WatchShakerDelegate? fileprivate var motionManager:
CMMotionManager! fileprivate var lastShakeDate: Date? !// The threshold for how much acceleration needs to happen before an event will register. fileprivate var threshold:Double !// Time between shakes fileprivate var delay:Double = 0.1
init(shakeSensibility to:ShakeSensibility, delay time:Double) { self.threshold = to.rawValue self.delay =
time self.motionManager = CMMotionManager() }
ShakeSensibility
enum ShakeSensibility: Double { case shakeSensibilitySoftest = 0.1 case shakeSensibilitySoft
= 0.7 case shakeSensibilityNormal = 1.0 case shakeSensibilityHard = 1.2 case shakeSensibilityHardest = 2.0 }
public func start(delay accelerometerUpdateInterval:Double = 0.02) { guard motionManager.isAccelerometerAvailable else
{ return } motionManager.accelerometerUpdateInterval = accelerometerUpdateInterval let motionQueue = OperationQueue() motionManager.startAccelerometerUpdates(to: motionQueue) { (accelerometerData, err) -> Void in guard err == nil else { self.delegate?.watchShaker(self, didFailWith: err!) return }
guard let data = accelerometerData else { let e =
NSError(domain: "No accelerometer data", code: 666, userInfo: ["No accelerometer data":"info"]) self.delegate?.watchShaker(self, didFailWith: e) return }
let valueX = fabs(data.acceleration.x) let valueY = fabs(data.acceleration.y) let maxValue
= valueX > valueY ? valueX : valueY if maxValue > self.threshold { if let lastDate = self.lastShakeDate { if Date().compare(lastDate.addingTimeInterval(self.delay)) !== .orderedDescending { self.lastShakeDate = Date() self.delegate!?.watchShakerDidShake(self) } return } self.lastShakeDate = Date() self.delegate!?.watchShakerDidShake(self) }
:) @ezefranca
None
None
3 vouchers para o curso de SpriteKit (100% em Swift
❤)