{"abstract":[{"text":"Create connections between your app’s data model and views.","type":"text"}],"hierarchy":{"paths":[["doc:\/\/com.apple.documentation\/documentation\/technologies","doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI","doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Model-data"]]},"identifier":{"interfaceLanguage":"swift","url":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Managing-model-data-in-your-app"},"kind":"article","legalNotices":{"copyright":"Copyright &copy; 2026 Apple Inc. All rights reserved.","privacyPolicy":"https:\/\/www.apple.com\/privacy\/privacy-policy","termsOfUse":"https:\/\/www.apple.com\/legal\/internet-services\/terms\/site.html"},"metadata":{"availableLanguages":["de-DE","en-US","es-419","fr-FR","it-IT","ja-JP","ko-KR","pt-BR","zh-CN"],"modules":[{"name":"SwiftUI"}],"platforms":[{"beta":false,"introducedAt":"17.0","name":"iOS"},{"beta":false,"introducedAt":"17.0","name":"iPadOS"},{"beta":false,"introducedAt":"17.0","name":"Mac Catalyst"},{"beta":false,"introducedAt":"14.0","name":"macOS"},{"beta":false,"introducedAt":"15.0","name":"Xcode"}],"role":"sampleCode","roleHeading":"Sample Code","title":"Managing model data in your app"},"primaryContentSections":[{"content":[{"anchor":"Overview","level":2,"text":"Overview","type":"heading"},{"inlineContent":[{"text":"A SwiftUI app can display data that people can change using the app’s user","type":"text"},{"text":" ","type":"text"},{"text":"interface (UI). To manage that data, an app creates a data model, which is a","type":"text"},{"text":" ","type":"text"},{"text":"custom type that represents the data. A data model provides separation between","type":"text"},{"text":" ","type":"text"},{"text":"the data and the views that interact with the data. This separation promotes","type":"text"},{"text":" ","type":"text"},{"text":"modularity, improves testability, and helps make it easier to reason about how","type":"text"},{"text":" ","type":"text"},{"text":"the app works.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"Keeping the model data (that is, an instance of a data model) in sync with what","type":"text"},{"text":" ","type":"text"},{"text":"appears on the screen can be challenging, especially when the data appears in","type":"text"},{"text":" ","type":"text"},{"text":"multiple views of the UI at the same time.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"SwiftUI helps keep your app’s UI up to date with changes made to the data","type":"text"},{"text":" ","type":"text"},{"text":"thanks to Observation. With ","type":"text"},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation","isActive":true,"type":"reference"},{"text":",","type":"text"},{"text":" ","type":"text"},{"text":"a view in SwiftUI can form dependencies on observable data models and update","type":"text"},{"text":" ","type":"text"},{"text":"the UI when data changes.","type":"text"}],"type":"paragraph"},{"content":[{"inlineContent":[{"text":"","type":"text"},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation","isActive":true,"type":"reference"},{"text":" support in","type":"text"},{"text":" ","type":"text"},{"text":"SwiftUI is available starting with iOS 17, iPadOS 17, macOS 14, tvOS 17, and","type":"text"},{"text":" ","type":"text"},{"text":"watchOS 10. For information about adopting Observation in existing apps, see","type":"text"},{"text":" ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Migrating-from-the-observable-object-protocol-to-the-observable-macro","isActive":true,"type":"reference"},{"text":".","type":"text"}],"type":"paragraph"}],"name":"Note","style":"note","type":"aside"},{"anchor":"Make-model-data-observable","level":3,"text":"Make model data observable","type":"heading"},{"inlineContent":[{"text":"To make data changes visible to SwiftUI, apply the","type":"text"},{"text":" ","type":"text"},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation\/Observable()","isActive":true,"type":"reference"},{"text":" ","type":"text"},{"text":"macro to your data model. This macro generates code that adds observation","type":"text"},{"text":" ","type":"text"},{"text":"support to your data model at compile time, keeping your data model code focused","type":"text"},{"text":" ","type":"text"},{"text":"on the properties that store data. For example, the following code defines a","type":"text"},{"text":" ","type":"text"},{"text":"data model for books:","type":"text"}],"type":"paragraph"},{"code":["@Observable class Book: Identifiable {","    var title = \"Sample Book Title\"","    var author = Author()","    var isAvailable = true","}"],"syntax":"swift","type":"codeListing"},{"content":[{"inlineContent":[{"text":"The ","type":"text"},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation\/Observable()","isActive":true,"type":"reference"},{"text":"","type":"text"},{"text":" ","type":"text"},{"text":"macro, in addition to adding observation functionality, also conforms your data","type":"text"},{"text":" ","type":"text"},{"text":"model type to the ","type":"text"},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation\/Observable","isActive":true,"type":"reference"},{"text":" ","type":"text"},{"text":"protocol, which serves as a signal to other APIs that your type supports","type":"text"},{"text":" ","type":"text"},{"text":"observation. Don’t apply the ","type":"text"},{"code":"Observable","type":"codeVoice"},{"text":" protocol by itself to your data model","type":"text"},{"text":" ","type":"text"},{"text":"type, since that alone doesn’t add any observation functionality. Instead,","type":"text"},{"text":" ","type":"text"},{"text":"always use the ","type":"text"},{"code":"Observable","type":"codeVoice"},{"text":" macro when adding observation support to your type.","type":"text"}],"type":"paragraph"}],"name":"Important","style":"important","type":"aside"},{"anchor":"Observe-model-data-in-a-view","level":3,"text":"Observe model data in a view","type":"heading"},{"inlineContent":[{"text":"In SwiftUI, a view forms a dependency on an observable data model object, such","type":"text"},{"text":" ","type":"text"},{"text":"as an instance of ","type":"text"},{"code":"Book","type":"codeVoice"},{"text":", when the view’s ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/body-8kl5o","isActive":true,"type":"reference"},{"text":" property","type":"text"},{"text":" ","type":"text"},{"text":"reads a property of the object. If ","type":"text"},{"code":"body","type":"codeVoice"},{"text":" doesn’t read any properties of an","type":"text"},{"text":" ","type":"text"},{"text":"observable data model object, the view doesn’t track any dependencies.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"When a tracked property changes, SwiftUI updates the view. If other properties","type":"text"},{"text":" ","type":"text"},{"text":"change that ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/body-8kl5o","isActive":true,"type":"reference"},{"text":" doesn’t read, the view is unaffected and","type":"text"},{"text":" ","type":"text"},{"text":"avoids unnecessary updates. For example, the view in the following code updates","type":"text"},{"text":" ","type":"text"},{"text":"only when a book’s ","type":"text"},{"code":"title","type":"codeVoice"},{"text":" changes but not when ","type":"text"},{"code":"author","type":"codeVoice"},{"text":" or ","type":"text"},{"code":"isAvailable","type":"codeVoice"},{"text":"","type":"text"},{"text":" ","type":"text"},{"text":"changes:","type":"text"}],"type":"paragraph"},{"code":["struct BookView: View {","    var book: Book","    ","    var body: some View {","        Text(book.title)","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"SwiftUI establishes this dependency tracking even if the view doesn’t store the","type":"text"},{"text":" ","type":"text"},{"text":"observable type, such as when using a global property or singleton:","type":"text"}],"type":"paragraph"},{"code":["var globalBook: Book = Book()","","struct BookView: View {","    var body: some View {","        Text(globalBook.title)","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"Observation also supports tracking of computed properties when the computed","type":"text"},{"text":" ","type":"text"},{"text":"property makes use of an observable property. For instance, the","type":"text"},{"text":" ","type":"text"},{"text":"view in the following code updates when the number of available books changes:","type":"text"}],"type":"paragraph"},{"code":["@Observable class Library {","    var books: [Book] = [Book(), Book(), Book()]","    ","    var availableBooksCount: Int {","        books.filter(\\.isAvailable).count","    }","}","","struct LibraryView: View {","    @Environment(Library.self) private var library","    ","    var body: some View {","        NavigationStack {","            List(library.books) { book in","                \/\/ ...","            }","            .navigationTitle(\"Books available: \\(library.availableBooksCount)\")","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"When a view forms a dependency on a collection of objects, of any collection","type":"text"},{"text":" ","type":"text"},{"text":"type, the view tracks changes made to the collection itself. For instance, the","type":"text"},{"text":" ","type":"text"},{"text":"view in the following code forms a dependency on ","type":"text"},{"code":"books","type":"codeVoice"},{"text":" because ","type":"text"},{"code":"body","type":"codeVoice"},{"text":" reads","type":"text"},{"text":" ","type":"text"},{"text":"it. As changes occur to ","type":"text"},{"code":"books","type":"codeVoice"},{"text":", such as inserting, deleting, moving, or","type":"text"},{"text":" ","type":"text"},{"text":"replacing items in the collection, SwiftUI updates the view.","type":"text"}],"type":"paragraph"},{"code":["struct LibraryView: View {","    @State private var books = [Book(), Book(), Book()]","","    var body: some View {","        List(books) { book in ","            Text(book.title)","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"However, ","type":"text"},{"code":"LibraryView","type":"codeVoice"},{"text":" doesn’t form a dependency on the property ","type":"text"},{"code":"title","type":"codeVoice"},{"text":" ","type":"text"},{"text":"because the view’s ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/body-8kl5o","isActive":true,"type":"reference"},{"text":" doesn’t read it directly. The","type":"text"},{"text":" ","type":"text"},{"text":"view stores the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/List","isActive":true,"type":"reference"},{"text":" content closure as an ","type":"text"},{"code":"@escaping","type":"codeVoice"},{"text":" closure that SwiftUI","type":"text"},{"text":" ","type":"text"},{"text":"calls when lazily creating list items before they appear on the screen. This","type":"text"},{"text":" ","type":"text"},{"text":"means that instead of ","type":"text"},{"code":"LibraryView","type":"codeVoice"},{"text":" depending on a book’s ","type":"text"},{"code":"title","type":"codeVoice"},{"text":", each","type":"text"},{"text":" ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Text","isActive":true,"type":"reference"},{"text":" item of the list depends on ","type":"text"},{"code":"title","type":"codeVoice"},{"text":". Any changes to a ","type":"text"},{"code":"title","type":"codeVoice"},{"text":" updates","type":"text"},{"text":" ","type":"text"},{"text":"only the individual ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Text","isActive":true,"type":"reference"},{"text":" representing the book and not the others.","type":"text"}],"type":"paragraph"},{"content":[{"inlineContent":[{"text":"Observation tracks changes to any observable property","type":"text"},{"text":" ","type":"text"},{"text":"that appears in the execution scope of a view’s ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/body-8kl5o","isActive":true,"type":"reference"},{"text":" ","type":"text"},{"text":"property.","type":"text"}],"type":"paragraph"}],"name":"Note","style":"note","type":"aside"},{"inlineContent":[{"text":"You can also share an observable model data object with another view. The","type":"text"},{"text":" ","type":"text"},{"text":"receiving view forms a dependency if it reads any properties of the object in","type":"text"},{"text":" ","type":"text"},{"text":"its ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/body-8kl5o","isActive":true,"type":"reference"},{"text":". For example, in the following code","type":"text"},{"text":" ","type":"text"},{"code":"LibraryView","type":"codeVoice"},{"text":" shares an instance of ","type":"text"},{"code":"Book","type":"codeVoice"},{"text":" with ","type":"text"},{"code":"BookView","type":"codeVoice"},{"text":", and ","type":"text"},{"code":"BookView","type":"codeVoice"},{"text":" ","type":"text"},{"text":"displays the book’s ","type":"text"},{"code":"title","type":"codeVoice"},{"text":". If the book’s ","type":"text"},{"code":"title","type":"codeVoice"},{"text":" changes, SwiftUI updates","type":"text"},{"text":" ","type":"text"},{"text":"only ","type":"text"},{"code":"BookView","type":"codeVoice"},{"text":", and not ","type":"text"},{"code":"LibraryView","type":"codeVoice"},{"text":", because only ","type":"text"},{"code":"BookView","type":"codeVoice"},{"text":" reads the","type":"text"},{"text":" ","type":"text"},{"code":"title","type":"codeVoice"},{"text":" property.","type":"text"}],"type":"paragraph"},{"code":["struct LibraryView: View {","    @State private var books = [Book(), Book(), Book()]","","    var body: some View {","        List(books) { book in ","            BookView(book: book)","        }","    }","}","","struct BookView: View {","    var book: Book","    ","    var body: some View {","        Text(book.title)","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"If a view doesn’t have any dependencies, SwiftUI doesn’t update the view when","type":"text"},{"text":" ","type":"text"},{"text":"data changes. This approach allows an observable model data object to pass","type":"text"},{"text":" ","type":"text"},{"text":"through multiple layers of a view hierarchy without each intermediate view","type":"text"},{"text":" ","type":"text"},{"text":"forming a dependency.","type":"text"}],"type":"paragraph"},{"code":["\/\/ Will not update when any property of `book` changes.","struct LibraryView: View {","    @State private var books = [Book(), Book(), Book()]","    ","    var body: some View {","        List(books) { book in ","            LibraryItemView(book: book)","        }","    }","}","","\/\/ Will not update when any property of `book` changes.","struct LibraryItemView: View {","    var book: Book","    ","    var body: some View {","        BookView(book: book)","    }","}","","\/\/ Will update when `book.title` changes.","struct BookView: View {","    var book: Book","    ","    var body: some View {","        Text(book.title)","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"However, a view that stores a reference to the observable object updates if the","type":"text"},{"text":" ","type":"text"},{"text":"reference changes. This happens because the stored reference is part of the","type":"text"},{"text":" ","type":"text"},{"text":"view’s value and not because the object is observable. For example, if the","type":"text"},{"text":" ","type":"text"},{"text":"reference to book in the following code changes, SwiftUI updates the view:","type":"text"}],"type":"paragraph"},{"code":["struct BookView: View {","    var book: Book","    ","    var body: some View {","        \/\/ ...","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"A view can also form a dependency on an observable data model object accessed","type":"text"},{"text":" ","type":"text"},{"text":"through another object. For example, the view in the following code updates","type":"text"},{"text":" ","type":"text"},{"text":"when the author’s ","type":"text"},{"code":"name","type":"codeVoice"},{"text":" changes:","type":"text"}],"type":"paragraph"},{"code":["struct LibraryItemView: View {","    var book: Book","    ","    var body: some View {","        VStack(alignment: .leading) {","            Text(book.title)","            Text(\"Written by: \\(book.author.name)\")","                .font(.caption)","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"anchor":"Create-the-source-of-truth-for-model-data","level":3,"text":"Create the source of truth for model data","type":"heading"},{"inlineContent":[{"text":"To create and store the source of truth for model data, declare a private","type":"text"},{"text":" ","type":"text"},{"text":"variable and initialize it with a instance of an observable data model type.","type":"text"},{"text":" ","type":"text"},{"text":"Then add the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/State()","isActive":true,"type":"reference"},{"text":" macro to declare that SwiftUI manages the property. For example, the","type":"text"},{"text":" ","type":"text"},{"text":"following code stores an instance of the data model type ","type":"text"},{"code":"Book","type":"codeVoice"},{"text":" in the state","type":"text"},{"text":" ","type":"text"},{"text":"variable ","type":"text"},{"code":"book","type":"codeVoice"},{"text":":","type":"text"}],"type":"paragraph"},{"code":["struct BookView: View {","    @State private var book = Book()","    ","    var body: some View {","        Text(book.title)","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"By wrapping the book with ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/State()","isActive":true,"type":"reference"},{"text":", you’re telling SwiftUI to manage the","type":"text"},{"text":" ","type":"text"},{"text":"storage of the instance. Each time SwiftUI re-creates ","type":"text"},{"code":"BookView","type":"codeVoice"},{"text":", it connects","type":"text"},{"text":" ","type":"text"},{"text":"the ","type":"text"},{"code":"book","type":"codeVoice"},{"text":" variable to the managed instance, providing the view a single source","type":"text"},{"text":" ","type":"text"},{"text":"of truth for the model data.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"You can also create a state object in your top-level ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/App","isActive":true,"type":"reference"},{"text":" instance or in one","type":"text"},{"text":" ","type":"text"},{"text":"of your app’s ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Scene","isActive":true,"type":"reference"},{"text":" instances. For example, the following code creates an","type":"text"},{"text":" ","type":"text"},{"text":"instance of ","type":"text"},{"code":"Library","type":"codeVoice"},{"text":" in the app’s top-level structure:","type":"text"}],"type":"paragraph"},{"code":["@main","struct BookReaderApp: App {","    @State private var library = Library()","    ","    var body: some Scene {","        WindowGroup {","            LibraryView()","                .environment(library)","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"anchor":"Share-model-data-throughout-a-view-hierarchy","level":3,"text":"Share model data throughout a view hierarchy","type":"heading"},{"inlineContent":[{"text":"If you have a data model object, like ","type":"text"},{"code":"Library","type":"codeVoice"},{"text":", that you want to share","type":"text"},{"text":" ","type":"text"},{"text":"throughout your app, you can either:","type":"text"}],"type":"paragraph"},{"items":[{"content":[{"inlineContent":[{"text":"pass the data model object to each view in the view hierarchy; or","type":"text"}],"type":"paragraph"}]},{"content":[{"inlineContent":[{"text":"add the data model object to the view’s environment","type":"text"}],"type":"paragraph"}]}],"type":"unorderedList"},{"inlineContent":[{"text":"Passing model data to each view is convenient when you have a shallow view","type":"text"},{"text":" ","type":"text"},{"text":"hierarchy; for example, when a view doesn’t share the object with its subviews.","type":"text"},{"text":" ","type":"text"},{"text":"However, you usually don’t know if a view needs to pass the object to","type":"text"},{"text":" ","type":"text"},{"text":"subviews, and you may not know if a subview deep inside the layers of the","type":"text"},{"text":" ","type":"text"},{"text":"hierarchy needs the model data.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"To share model data throughout a view hierarchy without needing to pass it to","type":"text"},{"text":" ","type":"text"},{"text":"each view, add the model data to the view’s environment. You can add the data","type":"text"},{"text":" ","type":"text"},{"text":"to the environment using either ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:_:)","isActive":true,"type":"reference"},{"text":" or the","type":"text"},{"text":" ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:)","isActive":true,"type":"reference"},{"text":" modifier, passing in the model data.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"Before you can use the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:_:)","isActive":true,"type":"reference"},{"text":" modifier, you need to create","type":"text"},{"text":" ","type":"text"},{"text":"a custom ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/EnvironmentKey","isActive":true,"type":"reference"},{"text":". Then extend ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/EnvironmentValues","isActive":true,"type":"reference"},{"text":" to include a","type":"text"},{"text":" ","type":"text"},{"text":"custom environment property that gets and sets the value for the custom key.","type":"text"},{"text":" ","type":"text"},{"text":"For instance, the following code creates an environment key and property for","type":"text"},{"text":" ","type":"text"},{"code":"library","type":"codeVoice"},{"text":":","type":"text"}],"type":"paragraph"},{"code":["extension EnvironmentValues {","    var library: Library {","        get { self[LibraryKey.self] }","        set { self[LibraryKey.self] = newValue }","    }","}","","private struct LibraryKey: EnvironmentKey {","    static let defaultValue: Library = Library()","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"With the custom environment key and property in place, a view can add model","type":"text"},{"text":" ","type":"text"},{"text":"data to its environment. For example, ","type":"text"},{"code":"LibraryView","type":"codeVoice"},{"text":" adds the source of truth","type":"text"},{"text":" ","type":"text"},{"text":"for a ","type":"text"},{"code":"Library","type":"codeVoice"},{"text":" instance to its environment using the","type":"text"},{"text":" ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:_:)","isActive":true,"type":"reference"},{"text":" modifier:","type":"text"}],"type":"paragraph"},{"code":["@main","struct BookReaderApp: App {","    @State private var library = Library()","    ","    var body: some Scene {","        WindowGroup {","            LibraryView()","                .environment(\\.library, library)","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"To retrieve the ","type":"text"},{"code":"Library","type":"codeVoice"},{"text":" instance from the environment, a view defines a local","type":"text"},{"text":" ","type":"text"},{"text":"variable that stores a reference to the instance, and then wraps the variable","type":"text"},{"text":" ","type":"text"},{"text":"with the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Environment","isActive":true,"type":"reference"},{"text":" property wrapper, passing in the key path to the","type":"text"},{"text":" ","type":"text"},{"text":"custom environment value.","type":"text"}],"type":"paragraph"},{"code":["struct LibraryView: View {","    @Environment(\\.library) private var library","","    var body: some View {","        \/\/ ...","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"You can also store model data directly in the environment without defining a","type":"text"},{"text":" ","type":"text"},{"text":"custom environment value by using the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:)","isActive":true,"type":"reference"},{"text":" modifier.","type":"text"},{"text":" ","type":"text"},{"text":"For instance, the following code adds a ","type":"text"},{"code":"Library","type":"codeVoice"},{"text":" instance to the environment","type":"text"},{"text":" ","type":"text"},{"text":"using this modifier:","type":"text"}],"type":"paragraph"},{"code":["@main","struct BookReaderApp: App {","    @State private var library = Library()","    ","    var body: some Scene {","        WindowGroup {","            LibraryView()","                .environment(library)","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"To retrieve the instance from the environment, another view defines a local","type":"text"},{"text":" ","type":"text"},{"text":"variable to store the instance and wraps it with the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Environment","isActive":true,"type":"reference"},{"text":" property","type":"text"},{"text":" ","type":"text"},{"text":"wrapper. But instead of providing a key path to the environment value, you can","type":"text"},{"text":" ","type":"text"},{"text":"provide the model data type, as shown in the following code:","type":"text"}],"type":"paragraph"},{"code":["struct LibraryView: View {","    @Environment(Library.self) private var library","    ","    var body: some View {","        \/\/ ...","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"By default, reading an object from the environment returns a non-optional","type":"text"},{"text":" ","type":"text"},{"text":"object when using the object type as the key. This default behavior assumes","type":"text"},{"text":" ","type":"text"},{"text":"that a view in the current hierarchy previously stored a non-optional instance","type":"text"},{"text":" ","type":"text"},{"text":"of the type using the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:)","isActive":true,"type":"reference"},{"text":" modifier. If a view","type":"text"},{"text":" ","type":"text"},{"text":"attempts to retrieve an object using its type and that object isn’t in the","type":"text"},{"text":" ","type":"text"},{"text":"environment, SwiftUI throws exception.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"In cases where there is no guarantee that an object is in the environment,","type":"text"},{"text":" ","type":"text"},{"text":"retrieve an optional version of the object as shown in the following code. If","type":"text"},{"text":" ","type":"text"},{"text":"the object isn’t available in the environment, SwiftUI returns ","type":"text"},{"code":"nil","type":"codeVoice"},{"text":" instead of","type":"text"},{"text":" ","type":"text"},{"text":"throwing an exception.","type":"text"}],"type":"paragraph"},{"code":["@Environment(Library.self) private var library: Library?"],"syntax":"swift","type":"codeListing"},{"anchor":"Change-model-data-in-a-view","level":3,"text":"Change model data in a view","type":"heading"},{"inlineContent":[{"text":"In most apps, people can change data that the app presents. When data changes,","type":"text"},{"text":" ","type":"text"},{"text":"any views that display the data should update to reflect the changed data. With","type":"text"},{"text":" ","type":"text"},{"text":"Observation in SwiftUI, a view can support data changes without using property","type":"text"},{"text":" ","type":"text"},{"text":"wrappers or bindings. For example, the following toggles the ","type":"text"},{"code":"isAvailable","type":"codeVoice"},{"text":"","type":"text"},{"text":" ","type":"text"},{"text":"property of a book in the action closure of a button:","type":"text"}],"type":"paragraph"},{"code":["struct BookView: View {","    var book: Book","    ","    var body: some View {","        List {","            Text(book.title)","            HStack {","                Text(book.isAvailable ? \"Available for checkout\" : \"Waiting for return\")","                Spacer()","                Button(book.isAvailable ? \"Check out\" : \"Return\") {","                    book.isAvailable.toggle()","                }","            }","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"However, there may be times when a view expects a binding before it can change","type":"text"},{"text":" ","type":"text"},{"text":"the value of a mutable property. To provide a binding, wrap the model data with","type":"text"},{"text":" ","type":"text"},{"text":"the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Bindable","isActive":true,"type":"reference"},{"text":" property wrapper. For example, the following code wraps the","type":"text"},{"text":" ","type":"text"},{"code":"book","type":"codeVoice"},{"text":" variable with ","type":"text"},{"code":"@Bindable","type":"codeVoice"},{"text":". Then it uses a ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/TextField","isActive":true,"type":"reference"},{"text":" to change the","type":"text"},{"text":" ","type":"text"},{"code":"title","type":"codeVoice"},{"text":" property of a book, and a ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Toggle","isActive":true,"type":"reference"},{"text":" to change the ","type":"text"},{"code":"isAvailable","type":"codeVoice"},{"text":"","type":"text"},{"text":" ","type":"text"},{"text":"property, using the ","type":"text"},{"code":"$","type":"codeVoice"},{"text":" syntax to pass a binding to each property.","type":"text"}],"type":"paragraph"},{"code":["struct BookEditView: View {","    @Bindable var book: Book","    @Environment(\\.dismiss) private var dismiss","    ","    var body: some View {","        VStack() {","            HStack {","                Text(\"Title\")","                TextField(\"Title\", text: $book.title)","                    .textFieldStyle(.roundedBorder)","                    .onSubmit {","                        dismiss()","                    }","            }","            ","            Toggle(isOn: $book.isAvailable) {","                Text(\"Book is available\")","            }","            ","            Button(\"Close\") {","                dismiss()","            }","            .buttonStyle(.borderedProminent)","        }","        .padding()","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"You can use the ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Bindable","isActive":true,"type":"reference"},{"text":" property wrapper on properties and variables to an","type":"text"},{"text":" ","type":"text"},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation\/Observable","isActive":true,"type":"reference"},{"text":" ","type":"text"},{"text":"object. This includes global variables, properties that exist outside of","type":"text"},{"text":" ","type":"text"},{"text":"SwiftUI types, or even local variables. For example, you can create a","type":"text"},{"text":" ","type":"text"},{"code":"@Bindable","type":"codeVoice"},{"text":" variable within a view’s ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/body-8kl5o","isActive":true,"type":"reference"},{"text":":","type":"text"}],"type":"paragraph"},{"code":["struct LibraryView: View {","    @State private var books = [Book(), Book(), Book()]","","    var body: some View {","        List(books) { book in ","            @Bindable var book = book","            TextField(\"Title\", text: $book.title)","        }","    }","}"],"syntax":"swift","type":"codeListing"},{"inlineContent":[{"text":"The ","type":"text"},{"code":"@Bindable","type":"codeVoice"},{"text":" variable ","type":"text"},{"code":"book","type":"codeVoice"},{"text":" provides a binding that connects ","type":"text"},{"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/TextField","isActive":true,"type":"reference"},{"text":" to","type":"text"},{"text":" ","type":"text"},{"text":"the ","type":"text"},{"code":"title","type":"codeVoice"},{"text":" property of a book so that a person can make changes directly to","type":"text"},{"text":" ","type":"text"},{"text":"the model data.","type":"text"}],"type":"paragraph"}],"kind":"content"}],"sampleCodeDownload":{"action":{"identifier":"6c08da4d9562\/ManagingModelDataSample.zip","isActive":true,"overridingTitle":"Download","type":"reference"},"kind":"sampleDownload"},"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"seeAlsoSections":[{"anchor":"Creating-model-data","generated":true,"identifiers":["doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Migrating-from-the-observable-object-protocol-to-the-observable-macro","doc:\/\/com.apple.documentation\/documentation\/Observation\/Observable()","doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Monitoring-model-data-changes-in-your-app","doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/StateObject","doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/ObservedObject","doc:\/\/com.apple.documentation\/documentation\/Combine\/ObservableObject"],"title":"Creating model data"}],"variants":[{"paths":["\/documentation\/swiftui\/managing-model-data-in-your-app"],"traits":[{"interfaceLanguage":"swift"}]}],"references":{"6c08da4d9562/ManagingModelDataSample.zip":{"checksum":null,"identifier":"6c08da4d9562\/ManagingModelDataSample.zip","type":"download","url":"6c08da4d9562\/ManagingModelDataSample.zip"},"SwiftUI-PageImage-card.png":{"alt":"A stylized Swift logo using dashes on a white or blue background.","identifier":"SwiftUI-PageImage-card.png","type":"image","variants":[{"traits":["2x","light"],"url":"\/images\/com.apple.SwiftUI\/SwiftUI-PageImage-card@2x.png"},{"traits":["2x","dark"],"url":"\/images\/com.apple.SwiftUI\/SwiftUI-PageImage-card~dark@2x.png"}]},"doc://com.apple.SwiftUI/documentation/SwiftUI":{"abstract":[{"text":"Declare the user interface and behavior for your app on every platform.","type":"text"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI","images":[{"identifier":"SwiftUI-PageImage-card.png","type":"card"}],"kind":"symbol","role":"collection","title":"SwiftUI","type":"topic","url":"\/documentation\/swiftui"},"doc://com.apple.SwiftUI/documentation/SwiftUI/App":{"abstract":[{"text":"A type that represents the structure and behavior of an app.","type":"text"}],"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"App"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/App","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"App"}],"role":"symbol","title":"App","type":"topic","url":"\/documentation\/swiftui\/app"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Bindable":{"abstract":[{"text":"A property wrapper type that supports creating bindings to the mutable","type":"text"},{"text":" ","type":"text"},{"text":"properties of observable objects.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"Bindable"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Bindable","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"Bindable"}],"role":"symbol","title":"Bindable","type":"topic","url":"\/documentation\/swiftui\/bindable"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Environment":{"abstract":[{"text":"A property wrapper that reads a value from a view’s environment.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"Environment"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Environment","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"Environment"}],"role":"symbol","title":"Environment","type":"topic","url":"\/documentation\/swiftui\/environment"},"doc://com.apple.SwiftUI/documentation/SwiftUI/EnvironmentKey":{"abstract":[{"text":"A key for accessing values in the environment.","type":"text"}],"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"EnvironmentKey"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/EnvironmentKey","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"EnvironmentKey"}],"role":"symbol","title":"EnvironmentKey","type":"topic","url":"\/documentation\/swiftui\/environmentkey"},"doc://com.apple.SwiftUI/documentation/SwiftUI/EnvironmentValues":{"abstract":[{"text":"A collection of environment values propagated through a view hierarchy.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"EnvironmentValues"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/EnvironmentValues","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"EnvironmentValues"}],"role":"symbol","title":"EnvironmentValues","type":"topic","url":"\/documentation\/swiftui\/environmentvalues"},"doc://com.apple.SwiftUI/documentation/SwiftUI/List":{"abstract":[{"text":"A container that presents rows of data arranged in a single column,","type":"text"},{"text":" ","type":"text"},{"text":"optionally providing the ability to select one or more members.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"List"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/List","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"List"}],"role":"symbol","title":"List","type":"topic","url":"\/documentation\/swiftui\/list"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Migrating-from-the-observable-object-protocol-to-the-observable-macro":{"abstract":[{"text":"Update your existing app to leverage the benefits of Observation in Swift.","type":"text"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Migrating-from-the-observable-object-protocol-to-the-observable-macro","kind":"article","role":"sampleCode","title":"Migrating from the Observable Object protocol to the Observable macro","type":"topic","url":"\/documentation\/swiftui\/migrating-from-the-observable-object-protocol-to-the-observable-macro"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Model-data":{"abstract":[{"text":"Manage the data that your app uses to drive its interface.","type":"text"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Model-data","kind":"article","role":"collectionGroup","title":"Model data","type":"topic","url":"\/documentation\/swiftui\/model-data"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Monitoring-model-data-changes-in-your-app":{"abstract":[{"text":"Show changes to data in your app’s user interface by using observable","type":"text"},{"text":" ","type":"text"},{"text":"objects.","type":"text"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Monitoring-model-data-changes-in-your-app","kind":"article","role":"sampleCode","title":"Monitoring data changes in your app","type":"topic","url":"\/documentation\/swiftui\/monitoring-model-data-changes-in-your-app"},"doc://com.apple.SwiftUI/documentation/SwiftUI/ObservedObject":{"abstract":[{"text":"A property wrapper type that subscribes to an observable object and","type":"text"},{"text":" ","type":"text"},{"text":"invalidates a view whenever the observable object changes.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"ObservedObject"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/ObservedObject","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"ObservedObject"}],"role":"symbol","title":"ObservedObject","type":"topic","url":"\/documentation\/swiftui\/observedobject"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Scene":{"abstract":[{"text":"A part of an app’s user interface with a life cycle managed by the","type":"text"},{"text":" ","type":"text"},{"text":"system.","type":"text"}],"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"Scene"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Scene","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"Scene"}],"role":"symbol","title":"Scene","type":"topic","url":"\/documentation\/swiftui\/scene"},"doc://com.apple.SwiftUI/documentation/SwiftUI/State()":{"abstract":[{"text":"Creates a property that can read and write a value managed by SwiftUI.","type":"text"}],"fragments":[{"kind":"keyword","text":"macro"},{"kind":"text","text":" "},{"kind":"identifier","text":"State"},{"kind":"text","text":"()"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/State()","kind":"symbol","role":"symbol","title":"State()","type":"topic","url":"\/documentation\/swiftui\/state()"},"doc://com.apple.SwiftUI/documentation/SwiftUI/StateObject":{"abstract":[{"text":"A property wrapper type that instantiates an observable object.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"StateObject"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/StateObject","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"StateObject"}],"role":"symbol","title":"StateObject","type":"topic","url":"\/documentation\/swiftui\/stateobject"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Text":{"abstract":[{"text":"A view that displays one or more lines of read-only text.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"Text"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Text","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"Text"}],"role":"symbol","title":"Text","type":"topic","url":"\/documentation\/swiftui\/text"},"doc://com.apple.SwiftUI/documentation/SwiftUI/TextField":{"abstract":[{"text":"A control that displays an editable text interface.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"TextField"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/TextField","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"TextField"}],"role":"symbol","title":"TextField","type":"topic","url":"\/documentation\/swiftui\/textfield"},"doc://com.apple.SwiftUI/documentation/SwiftUI/Toggle":{"abstract":[{"text":"A control that toggles between on and off states.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"Toggle"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/Toggle","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"Toggle"}],"role":"symbol","title":"Toggle","type":"topic","url":"\/documentation\/swiftui\/toggle"},"doc://com.apple.SwiftUI/documentation/SwiftUI/View/body-8kl5o":{"abstract":[{"text":"The content and behavior of the view.","type":"text"}],"defaultImplementations":6,"fragments":[{"kind":"keyword","text":"var"},{"kind":"text","text":" "},{"kind":"identifier","text":"body"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"Self"},{"kind":"text","text":"."},{"kind":"typeIdentifier","preciseIdentifier":"s:7SwiftUI4ViewP4BodyQa","text":"Body"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/body-8kl5o","kind":"symbol","required":true,"role":"symbol","title":"body","type":"topic","url":"\/documentation\/swiftui\/view\/body-8kl5o"},"doc://com.apple.SwiftUI/documentation/SwiftUI/View/environment(_:)":{"abstract":[{"text":"Places an observable object in the view’s environment.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"environment"},{"kind":"text","text":"<"},{"kind":"genericParameter","text":"T"},{"kind":"text","text":">("},{"kind":"typeIdentifier","text":"T"},{"kind":"text","text":"?) -> "},{"kind":"keyword","text":"some"},{"kind":"text","text":" "},{"kind":"typeIdentifier","preciseIdentifier":"s:7SwiftUI4ViewP","text":"View"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:)","kind":"symbol","role":"symbol","title":"environment(_:)","type":"topic","url":"\/documentation\/swiftui\/view\/environment(_:)"},"doc://com.apple.SwiftUI/documentation/SwiftUI/View/environment(_:_:)":{"abstract":[{"text":"Sets the environment value of the specified key path to the given value.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"environment"},{"kind":"text","text":"<"},{"kind":"genericParameter","text":"V"},{"kind":"text","text":">("},{"kind":"typeIdentifier","preciseIdentifier":"s:s15WritableKeyPathC","text":"WritableKeyPath"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","preciseIdentifier":"s:7SwiftUI17EnvironmentValuesV","text":"EnvironmentValues"},{"kind":"text","text":", "},{"kind":"typeIdentifier","text":"V"},{"kind":"text","text":">, "},{"kind":"typeIdentifier","text":"V"},{"kind":"text","text":") -> "},{"kind":"keyword","text":"some"},{"kind":"text","text":" "},{"kind":"typeIdentifier","preciseIdentifier":"s:7SwiftUI4ViewP","text":"View"}],"identifier":"doc:\/\/com.apple.SwiftUI\/documentation\/SwiftUI\/View\/environment(_:_:)","kind":"symbol","role":"symbol","title":"environment(_:_:)","type":"topic","url":"\/documentation\/swiftui\/view\/environment(_:_:)"},"doc://com.apple.documentation/documentation/Combine/ObservableObject":{"abstract":[{"text":"A type of object with a publisher that emits before the object has changed.","type":"text"}],"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"ObservableObject"}],"identifier":"doc:\/\/com.apple.documentation\/documentation\/Combine\/ObservableObject","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"ObservableObject"}],"role":"symbol","title":"ObservableObject","type":"topic","url":"\/documentation\/combine\/observableobject"},"doc://com.apple.documentation/documentation/Observation":{"abstract":[{"text":"Make responsive apps that update the presentation when underlying data changes.","type":"text"}],"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation","kind":"symbol","role":"collection","title":"Observation","type":"topic","url":"\/documentation\/observation"},"doc://com.apple.documentation/documentation/Observation/Observable":{"abstract":[{"text":"A type that emits notifications to observers when underlying data changes.","type":"text"}],"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"Observable"}],"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation\/Observable","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"Observable"}],"role":"symbol","title":"Observable","type":"topic","url":"\/documentation\/observation\/observable"},"doc://com.apple.documentation/documentation/Observation/Observable()":{"abstract":[{"text":"Defines and implements conformance of the Observable protocol.","type":"text"}],"fragments":[{"kind":"keyword","text":"macro"},{"kind":"text","text":" "},{"kind":"identifier","text":"Observable"},{"kind":"text","text":"()"}],"identifier":"doc:\/\/com.apple.documentation\/documentation\/Observation\/Observable()","kind":"symbol","role":"symbol","title":"Observable()","type":"topic","url":"\/documentation\/observation\/observable()"},"doc://com.apple.documentation/documentation/technologies":{"abstract":[],"identifier":"doc:\/\/com.apple.documentation\/documentation\/technologies","kind":"technologies","role":"overview","title":"Technologies","type":"topic","url":"\/documentation\/technologies"}}}