Contents

DeferredProperty(title:description:authenticationPolicy:visibility:)

A macro that adds an asynchronous app entity property with an asynchronous get accessor.

Declaration

@attached(peer, names: prefixed(`$`), prefixed(`_`)) @attached(accessor, names: named(get), named(set)) macro DeferredProperty(title: LocalizedStringResource? = nil, description: LocalizedStringResource? = nil, authenticationPolicy: IntentAuthenticationPolicy? = nil, visibility: IntentVisibility? = nil)

Parameters

  • title:

    A localized string resource describing the property for display in the user interface.

  • description:

    Additional details about this property.

  • authenticationPolicy:

    The authentication policy to enforce when the system accesses this property, or nil to use the entity’s policy.

  • visibility:

    Whether the property is available to system features, or only to your app, or nil for .default.

Overview

Example

struct Restaurant: AppEntity {
    var model: Menu

    @DeferredProperty(title: "Popular Items", authenticationPolicy: .requiresAuthentication)
    var popularItems: [MenuItem] {
        get async {
            await model.server.popularMenuItems()
        }
    }
}

See Also

Entity support