How to combine multiple property wrappers to update a SwiftUI View?

Published: 21 May 2021
on channel: Swift and Tips
1,193
56

Hello guys, welcome to another video!

There is more about property wrappers, today we will see if it's possible to use two or more wrappers at the same time, what about projected values, and finally how to update views in SwiftUI by using DynamicProperty protocol.

In the previous video, we talked about the basics of a property wrapper and wrappedValue, I recommend you to watch it first:    • Why property Wrappers are so importan...  

Let's get started! 😄

Content:
0:00 - Intro
0:53 - A preview of the final solution
1:17 - The Problem
1:41 - Setting up wrappedValue
3:39 - Setting up the format parameter
6:07 - Can we combine two property wrappers?
9:36 - Using @State inside a property wrapper
10:37 - Setting up a projectedValue
14:08 - Using nonmutating in wrappedValue
15:54 - Conforming DynamicProperty
18:10 - Running the final version
19:17 - Outro

------
References:
* propertyWrapper attribute: https://docs.swift.org/swift-book/Ref...
* Projecting a value: https://docs.swift.org/swift-book/Lan...
* DynamicProperty: https://davedelong.com/blog/2021/04/0...
* nonmutating: https://forums.swift.org/t/non-mutati...

Nesting property wrappers in Swift (by Noah Gilmore): https://noahgilmore.com/blog/nesting-...

Source code showed in the video: https://github.com/pitt500/swift-and-...

------
Other videos in the channel:
* State management in SwiftUI:    • State Management in SwiftUI  
* UIKit in SwiftUI:    • UIKit in SwiftUI  
* Generics:    • Generics  
* The power of Combine:    • The power of Combine  

-----
Don't forget to subscribe to the channel, like it, and follow me on social media:

Twitter:
  / swiftandtips  
  / pitt500  

Finally, ask me for a video you would like to see next 😄!

Credits:
- Music by Wataboi from https://pixabay.com/
- Video edited with LumaFusion


Watch video How to combine multiple property wrappers to update a SwiftUI View? online without registration, duration hours minute second in high quality. This video was added by user Swift and Tips 21 May 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,193 once and liked it 56 people.