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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Programming with a DJ Controller — not vibe coding
m_seki
3
840
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.9k
Firefoxにコントリビューションして得られた学び
ken7253
2
160
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
510
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
170
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
390
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
510
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
130
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
7
2.6k
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
23
12k
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
180
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
528
40k
Bash Introduction
62gerente
615
210k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Into the Great Unknown - MozCon
thekraken
41
2.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
370
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
140
Design in an AI World
tapps
1
210
My Coaching Mixtape
mlcsv
0
130
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
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