requestAssets(completionHandler:)
Requests embedding model assets and downloads them if available.
Declaration
func requestAssets(completionHandler: @escaping @Sendable (NLContextualEmbedding.AssetsResult, (any Error)?) -> Void)func requestAssets() async throws -> NLContextualEmbedding.AssetsResultParameters
- completionHandler:
A closure that notifies your app when the asset request completes.
Asynchronous alternative
You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
func requestAssets() async throws -> NLContextualEmbedding.AssetsResultFor information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.
Discussion
You use a contextual embedding after loading the necessary assets onto the device. Use hasAvailableAssets to determine whether assets are available. This method returns immediately if the framework knows the state of the assets or if an error occurs.