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
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.9k
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.2k
Speeding Up Your CI
yhkaplan
0
500
Automate All the Things
yhkaplan
4
2.5k
Other Decks in Programming
See All in Programming
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
470
Deno Tunnel を使ってみた話
kamekyame
0
280
チームをチームにするEM
hitode909
0
420
ThorVG Viewer In VS Code
nors
0
490
Tinkerbellから学ぶ、Podで DHCPをリッスンする手法
tomokon
0
150
開発に寄りそう自動テストの実現
goyoki
2
1.6k
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
1k
tparseでgo testの出力を見やすくする
utgwkk
2
330
[AI Engineering Summit Tokyo 2025] LLMは計画業務のゲームチェンジャーか? 最適化業務における活⽤の可能性と限界
terryu16
1
140
クラウドに依存しないS3を使った開発術
simesaba80
0
200
ローカルLLMを⽤いてコード補完を⾏う VSCode拡張機能を作ってみた
nearme_tech
PRO
0
210
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
520
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
58
41k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
For a Future-Friendly Web
brad_frost
180
10k
The SEO Collaboration Effect
kristinabergwall1
0
320
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
30
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
36
Git: the NoSQL Database
bkeepers
PRO
432
66k
What's in a price? How to price your products and services
michaelherold
246
13k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
1
37
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
140
The Mindset for Success: Future Career Progression
greggifford
PRO
0
200
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
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