Contents

updateCache(_:subviews:)

Updates the layout’s cache when something changes.

Declaration

func updateCache(_ cache: inout Self.Cache, subviews: Self.Subviews)

Parameters

  • cache:

    Storage for calculated data that you share among the methods of your custom layout container.

  • subviews:

    A collection of proxy instances that represent the views arranged by the container. You can use the proxies in the collection to get information about the subviews as you calculate values to store in the cache.

Discussion

If your custom layout container creates a cache by implementing the makeCache(subviews:) method, SwiftUI calls the update method when your layout or its subviews change, giving you an opportunity to modify or invalidate the contents of the cache. The method’s default implementation recreates the cache by calling the makeCache(subviews:) method, but you can provide your own implementation to take an incremental approach, if appropriate.

See Also

Managing a cache