$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Property Wrappers
Search
yhkaplan
January 21, 2020
Programming
0
570
Property Wrappers
yhkaplan
January 21, 2020
Tweet
Share
More Decks by yhkaplan
See All by yhkaplan
Using the latest UICollectionView APIs
yhkaplan
0
2.8k
Swift and Concurrency: The Plan for World Domination
yhkaplan
0
190
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.1k
Speeding Up Your CI
yhkaplan
0
500
Automate All the Things
yhkaplan
4
2.5k
Other Decks in Programming
See All in Programming
Grafana:建立系統全知視角的捷徑
blueswen
0
200
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
190
AIコーディングエージェント(NotebookLM)
kondai24
0
230
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
160
Cell-Based Architecture
larchanjo
0
140
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
TestingOsaka6_Ozono
o3
0
170
Vibe codingでおすすめの言語と開発手法
uyuki234
0
110
tparseでgo testの出力を見やすくする
utgwkk
2
280
Combinatorial Interview Problems with Backtracking Solutions - From Imperative Procedural Programming to Declarative Functional Programming - Part 2
philipschwarz
PRO
0
110
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
190
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
370
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
0
190
Navigating Weather and Climate Data
rabernat
0
52
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
0
300
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
290
WCS-LA-2024
lcolladotor
0
390
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
0
31
Bash Introduction
62gerente
615
210k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
So, you think you're a good person
axbom
PRO
0
1.8k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
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