{"id":51920,"date":"2026-05-14T14:38:34","date_gmt":"2026-05-14T18:38:34","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=51920"},"modified":"2026-05-14T14:38:34","modified_gmt":"2026-05-14T18:38:34","slug":"swiftui-state-and-the-attribute-graph","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2026\/05\/14\/swiftui-state-and-the-attribute-graph\/","title":{"rendered":"SwiftUI: @State and the Attribute Graph"},"content":{"rendered":"<p><a href=\"https:\/\/fivestars.blog\/swiftui\/lets-build-state.html\">Federico Zanetello<\/a>:<\/p>\n<blockquote cite=\"https:\/\/fivestars.blog\/swiftui\/lets-build-state.html\">\n<p><a href=\"https:\/\/developer.apple.com\/documentation\/swiftui\/state\"><code>@State<\/code><\/a> is one of the many SwiftUI&rsquo;s pillars that, once understood, we take for granted and use pretty much everywhere without a second thought. But what is <code>@State<\/code>? What&rsquo;s happening behind the scenes?<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/www.nsvasilev.com\/posts\/swiftui-state\/\">Nikita Vasilev<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.nsvasilev.com\/posts\/swiftui-state\/\">\n<p>The answer is that <code>@State<\/code> does not store its value in the struct. The struct holds only a thin token - a reference to a node in an external, long-lived graph maintained by the SwiftUI runtime.<\/p>\n<p>[&#8230;]<\/p>\n<p>State in the Attribute Graph is owned by the view that declares it. Lifetime of the graph node is tied to the lifetime of that view&rsquo;s identity in the hierarchy.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/rensbr.eu\/blog\/swiftui-attribute-graph\/\">Rens Breur<\/a>:<\/p>\n<blockquote cite=\"https:\/\/rensbr.eu\/blog\/swiftui-attribute-graph\/\">\n<p>As is generally known, SwiftUI hands off some of its work to a private framework called AttributeGraph. In this article we will explore how SwiftUI uses that framework to efficiently update only those parts of an app necessary and to efficiently get the data out of your view graph it needs for rendering your app.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=7o6Fkj3buxM\">Chris Eidhof<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.youtube.com\/watch?v=7o6Fkj3buxM\">\n<p>In this talk, we&rsquo;ll look at the system that underpins SwiftUI: the attribute graph.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/02\/28\/making-friends-with-attributegraph\/\">Making Friends With AttributeGraph<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2023\/07\/06\/swiftui-data-flow-2023\/\">SwiftUI Data Flow 2023<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/09\/04\/the-swiftui-render-loop\/\">The SwiftUI Render Loop<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/03\/29\/lifetime-of-state-properties-in-swiftui\/\">Lifetime of State Properties in SwiftUI<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/07\/10\/gosh-darn-swiftui\/\">Gosh Darn SwiftUI<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Federico Zanetello: @State is one of the many SwiftUI&rsquo;s pillars that, once understood, we take for granted and use pretty much everywhere without a second thought. But what is @State? What&rsquo;s happening behind the scenes? Nikita Vasilev: The answer is that @State does not store its value in the struct. The struct holds only a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2026-05-14T18:38:38Z","apple_news_api_id":"12dd91b3-9926-4b11-b84f-4d0eea06bcc9","apple_news_api_modified_at":"2026-05-14T18:38:38Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AEt2Rs5kmSxG4T00O6ga8yQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[31,2741,30,2742,71,901,1812],"class_list":["post-51920","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-ios-26","tag-mac","tag-macos-tahoe-26","tag-programming","tag-swift-programming-language","tag-swiftui"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/51920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=51920"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/51920\/revisions"}],"predecessor-version":[{"id":51921,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/51920\/revisions\/51921"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=51920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=51920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=51920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}