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
600
0
Share
Property Wrappers
yhkaplan
January 21, 2020
More Decks by yhkaplan
See All by yhkaplan
Using the latest UICollectionView APIs
yhkaplan
0
3.2k
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
10 Tips of AWS ~Gen AI on AWS~
licux
5
400
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
330
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
340
ハーネスエンジニアリングとは?
kinopeee
10
5.2k
AIエージェントで業務改善してみた
taku271
0
530
[RubyKaigi 2026] Require Hooks
palkan
1
200
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
180
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
140
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
2
170
Angular Signal Forms
debug_mode
0
110
Vibe NLP for Applied NLP
inesmontani
PRO
0
430
ルールルルルルRubyの中身の予備知識 ── RubyKaigiの前に予習しなイカ?
ydah
1
180
Featured
See All Featured
Balancing Empowerment & Direction
lara
6
1.1k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
170
KATA
mclloyd
PRO
35
15k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
100
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
Skip the Path - Find Your Career Trail
mkilby
1
110
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
170
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.5k
Raft: Consensus for Rubyists
vanstee
141
7.4k
Automating Front-end Workflow
addyosmani
1370
200k
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