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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
yhkaplan
January 21, 2020
Programming
610
0
Share
Property Wrappers
yhkaplan
January 21, 2020
More Decks by yhkaplan
See All by yhkaplan
Using the latest UICollectionView APIs
yhkaplan
0
3.3k
Swift and Concurrency: The Plan for World Domination
yhkaplan
0
210
Backend-Driven UI: Making Screens Dynamic
yhkaplan
1
1.8k
Migrating from UIKit to SwiftUI efficiently
yhkaplan
4
3.8k
Parser Combinators
yhkaplan
0
310
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
Firefoxにコントリビューションして得られた学び
ken7253
2
160
My daily life on Ruby
a_matsuda
3
380
2026-04-15 Spring IO - I Can See Clearly Now
jonatan_ivanov
1
210
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
160
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.2k
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
23
12k
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.2k
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
380
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
160
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
130
Featured
See All Featured
Claude Code のすすめ
schroneko
67
220k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
910
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
120
Into the Great Unknown - MozCon
thekraken
41
2.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Rails Girls Zürich Keynote
gr2m
96
14k
BBQ
matthewcrist
89
10k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
570
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
190
Prompt Engineering for Job Search
mfonobong
0
300
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
420
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