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
240
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
エンジニアゼロの組織から内製開発の DX をどう実現したのか / How did we achieve DX in in-house development in an organization with zero engineers?
genkiogasawara
2
1k
TiDBにおけるテーブル設計と最適化の事例
cygames
0
760
データ分析力を高めるSQL研修サービス『SQL Everyone』
hikarut
1
370
kcp: Kubernetes APIs Are All You Need #techfeed_live / TechFeed Experts Night 28th
ytaka23
1
180
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
16
6.7k
Taking Flight with Tailwind CSS
opdavies
0
4.3k
TypescriptでのContextualな構造化ロギングと社内全体への導入
leveragestech
3
510
動画配信サービスのフロントエンド実装に学ぶ設計原則
yud0uhu
0
120
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
160
AWSの生成AI入門書を執筆しました🎉
minorun365
PRO
0
120
令和版ソフトウェアエンジニアの情報収集術 PHPカンファレンス香川2024
ysknsid25
4
840
QA経験のないエンジニアリング マネージャーがQAのカジュアル面談に出て 苦労していること・気づいたこと / scrum fest niigata 2024
yoshikiiida
2
630
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
22
1.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
4 Signs Your Business is Dying
shpigford
176
21k
How to Ace a Technical Interview
jacobian
273
22k
Scaling GitHub
holman
457
140k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
23
1.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
22
6.4k
GitHub's CSS Performance
jonrohan
1025
450k
[RailsConf 2023] Rails as a piece of cake
palkan
28
4k
Debugging Ruby Performance
tmm1
70
11k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
123
39k
A designer walks into a library…
pauljervisheath
201
23k
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
❤)