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 Swif...
Search
Ezequiel Santos
May 17, 2017
Technology
0
270
[#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
Gamified Interventions for Composting Behavior: A Case Study Using the Gamiflow Framework in a Workplace Setting
ezefranca
1
7
Comparative Analysis of AI Models in Managing Household Food Waste: OpenAI GPT-4, Google Gemini, Mistral, and Anthropic Claude
ezefranca
0
140
Decision-making algorithms and Planning Algorithms
ezefranca
1
73
Dependency Management in iOS Development: A Developer Survey Perspective
ezefranca
0
130
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
350
Server-Driven UI na prática
ezefranca
0
290
Modelo Clássico e Jogos (Jesper Jull) e exergames.
ezefranca
0
140
Server Driven UI Diferença e evolução em 2010 e 2020
ezefranca
0
1.5k
[#2 Community day Shawee] Prototipação eletrônica em Hackathons: idéias makers ganhando vida
ezefranca
0
1.1k
Other Decks in Technology
See All in Technology
CodeRabbitと過ごした1ヶ月 ─ AIコードレビュー導入で実感したチーム開発の進化
mitohato14
1
240
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
7
63k
Vibe Coding Tools
ijin
0
120
時間がないなら、つくればいい 〜数十人規模のチームが自律性を発揮するために試しているいくつかのこと〜
kakehashi
PRO
23
5.3k
3D生成AIのための画像生成
kosukeito
2
620
MySQL InnoDB Data Recovery - The Last Resort
lefred
0
110
コードや知識を組み込む / Incorporating Codes and Knowledge
ks91
PRO
0
170
Асинхронная коммуникация в Go: от понятного к душному. Дима Некрасов, Otello, 2ГИС
lamodatech
0
2.1k
Google Cloud Next 2025 Recap アプリケーション開発を加速する機能アップデート / Application development-related features of Google Cloud
ryokotmng
0
140
『ささAI』ネタづくりをささえるAI📝 (にぼしいわし担当:GIFTech2025)
masapyon1212
0
110
非root化Androidスマホでも動く仮想マシンアプリを試してみた
arkw
0
120
CARTA HOLDINGS エンジニア向け 採用ピッチ資料 / CARTA-GUIDE-for-Engineers
carta_engineering
0
27k
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
24
2.7k
Rails Girls Zürich Keynote
gr2m
94
13k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
BBQ
matthewcrist
88
9.6k
Speed Design
sergeychernyshev
29
940
Measuring & Analyzing Core Web Vitals
bluesmoon
7
420
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
Become a Pro
speakerdeck
PRO
28
5.3k
Writing Fast Ruby
sferik
628
61k
4 Signs Your Business is Dying
shpigford
183
22k
GitHub's CSS Performance
jonrohan
1031
460k
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
❤)