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
Property Wrappers
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
yhkaplan
January 21, 2020
Programming
590
0
Share
Property Wrappers
yhkaplan
January 21, 2020
More Decks by yhkaplan
See All by yhkaplan
Using the latest UICollectionView APIs
yhkaplan
0
3.1k
Swift and Concurrency: The Plan for World Domination
yhkaplan
0
200
Backend-Driven UI: Making Screens Dynamic
yhkaplan
1
1.8k
Migrating from UIKit to SwiftUI efficiently
yhkaplan
4
3.8k
Parser Combinators
yhkaplan
0
300
The Great Swift Migration
yhkaplan
1
4.2k
Speeding Up Your CI
yhkaplan
0
510
Automate All the Things
yhkaplan
4
2.6k
Other Decks in Programming
See All in Programming
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
110
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
130
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
650
Java 21/25 Virtual Threads 소개
debop
0
320
Claude Code Skill入門
mayahoney
0
460
forteeの改修から振り返るPHPerKaigi 2026
muno92
PRO
3
110
Feature Toggle は捨てやすく使おう
gennei
0
400
OTP を自動で入力する裏技
megabitsenmzq
0
130
へんな働き方
yusukebe
6
2.9k
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
6
1.2k
RSAが破られる前に知っておきたい 耐量子計算機暗号(PQC)入門 / Intro to PQC: Preparing for the Post-RSA Era
mackey0225
3
110
Rethinking API Platform Filters
vinceamstoutz
0
5.1k
Featured
See All Featured
Are puppies a ranking factor?
jonoalderson
1
3.2k
The Invisible Side of Design
smashingmag
302
51k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
92
Rails Girls Zürich Keynote
gr2m
96
14k
Thoughts on Productivity
jonyablonski
76
5.1k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
370
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Believing is Seeing
oripsolob
1
100
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Done Done
chrislema
186
16k
The Curse of the Amulet
leimatthew05
1
11k
Transcript
Property Wrappers 1
What are they? 2
→ New in 5.1 → Java-like annotations → Can accept
(generic) parameters → Used in SwiftUI 3
Purpose 4
Examples 5
SwiftUI 6
struct ContentView: View { @State private var value = 0.0
var body: some View { VStack { Text("Value is \(value)") Slider(value: $value) } } } 7
UIKit/ Foundation 8
class ViewController: UIViewController { @Keychain(key: "secret_info") var secretInfo = ""
} 9
Let's make one! 10
@propertyWrapper struct TwelveOrLess { private var number = 0 var
wrappedValue: Int { get { return number } set { number = min(newValue, 12) } } } // Use struct S { @TwelveOrLess var num = 13 // 12 } 11
@propertyWrapper struct Clamped { private var number = 0 private
let maxNum: Int private let minNum: Int var wrappedValue: Int { get { return number } set { number = max(min(newValue, maxNum), minNum) } } } // Use struct S { @Clamped(maxNum: 10, minNum: 0) var num = 13 // 10 } 12
Projected values 13
@propertyWrapper struct State<T> { //... var projectedValue: Binding<T> } 14
struct ContentView: View { @State private var isDisabled = false
var body: some View { OtherView($isDisabled) // Binding<Bool> } } 15
Conclusion 16
More info 17
→ The Swift Programming Language → Burritos 18