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
yhkaplan
January 21, 2020
Programming
0
550
Property Wrappers
yhkaplan
January 21, 2020
Tweet
Share
More Decks by yhkaplan
See All by yhkaplan
Using the latest UICollectionView APIs
yhkaplan
0
2.4k
Swift and Concurrency: The Plan for World Domination
yhkaplan
0
180
Backend-Driven UI: Making Screens Dynamic
yhkaplan
1
1.7k
Migrating from UIKit to SwiftUI efficiently
yhkaplan
4
3.5k
Parser Combinators
yhkaplan
0
280
The Great Swift Migration
yhkaplan
1
4.1k
Speeding Up Your CI
yhkaplan
0
480
Automate All the Things
yhkaplan
4
2.4k
Other Decks in Programming
See All in Programming
Julia という言語について (FP in Julia « SIDE: F ») for 関数型まつり2025
antimon2
3
970
無関心の谷
kanayannet
0
180
GraphRAGの仕組みまるわかり
tosuri13
7
450
XP, Testing and ninja testing
m_seki
2
130
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
380
Perplexity Slack Botを作ってAI活用を進めた話 / AI Engineering Summit プレイベント
n3xem
0
670
レガシーシステムの機能調査・開発におけるAI利活用
takuya_ohtonari
0
610
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
1
270
実践ArchUnit ~実例による検証パターンの紹介~
ogiwarat
2
280
DroidKnights 2025 - 다양한 스크롤 뷰에서의 영상 재생
gaeun5744
3
300
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
41
28k
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
780
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
94
14k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
940
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
How STYLIGHT went responsive
nonsquared
100
5.6k
Speed Design
sergeychernyshev
31
1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
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