![]() ![]() ![]() This is an app I made called "Good Dog, Bad Dog," which helps me keep track of whether my furry friend has been on her best behavior. It's also a critical aspect of how SwiftUI understands your app. These Ruby Spaniels are adorable, but they're also the subject of a deep philosophical question.Īre these two different dogs? Or are these, in fact, two pictures of the same dog? The truth is, it's impossible to say! We just don't have enough information.īut this question of whether things are the same or different is at the heart of what we call "identity." Identity isn't just important for dogs though. Let's start with identity, and I have a few friends here to help me. Today, we'll talk about each of these three concepts in more depth. Together, these three concepts inform how SwiftUI decides what needs to change, how, and when, resulting in the dynamic user interface you see onscreen. Lifetime is how SwiftUI tracks the existence of views and data over time.Īnd dependencies are how SwiftUI understands when your interface needs to be updated and why. Identity is how SwiftUI recognizes elements as the same or distinct across multiple updates of your app. So today's question is, When SwiftUI looks at your code, what does it see? The answer is three things: identity, lifetime, and dependencies. Now, most of the time, this works great! And that's when SwiftUI feels magical.īut there will always be those moments when SwiftUI does something that you might not expect.Īnd in those moments, it helps to understand a bit more about what SwiftUI is doing behind the scenes to build a better intuition for how to get the results you're looking for. That means that you describe what you want for your app at a high level, and SwiftUI decides exactly how to make it happen. Now, we've heard it many times before that SwiftUI is a declarative UI framework. ♪ Bass music playing ♪ ♪ Matt Ricketson: Hi, I'm Matt, and later on I'll be joined by Luca and Raj. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |