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
0
580
Property Wrappers
yhkaplan
January 21, 2020
Tweet
Share
More Decks by yhkaplan
See All by yhkaplan
Using the latest UICollectionView APIs
yhkaplan
0
3k
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.7k
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
Go 1.26でのsliceのメモリアロケーション最適化 / Go 1.26 リリースパーティ #go126party
mazrean
1
330
浮動小数の比較について
kishikawakatsumi
0
370
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
500
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
1
120
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
320
CSC307 Lecture 12
javiergs
PRO
0
450
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
130
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
140
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
190
手戻りゼロ? Spec Driven Developmentとは@KAG AI week
tmhirai
1
140
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
190
Head of Engineeringが現場で回した生産性向上施策 2025→2026
gessy0129
0
210
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
We Are The Robots
honzajavorek
0
190
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
A Soul's Torment
seathinner
5
2.4k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.7k
Prompt Engineering for Job Search
mfonobong
0
180
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
280
Git: the NoSQL Database
bkeepers
PRO
432
66k
Chasing Engaging Ingredients in Design
codingconduct
0
130
A Tale of Four Properties
chriscoyier
162
24k
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