Type Method

requestAssets(for:tagScheme:completionHandler:)

Asks the Natural Language framework to load any missing assets for a tag scheme onto the device for the given language.

Declaration

class func requestAssets(for language: NLLanguage, tagScheme: NLTagScheme, completionHandler: @escaping (NLTagger.AssetsResult, Error?) -> Void)

Parameters

language

The language of the tag scheme that you’re asking the framework to load onto the device.

tagScheme

The tag scheme that you’re asking the framework to load onto the device.

completionHandler

A closure the framework uses to notify your app when the tag scheme request has completed.

Discussion

Before using this method, use availableTagSchemes(for:language:) to check whether a tag scheme is available on the device. When a tag scheme is unavailable for a specific language, it may be because the framework hasn’t loaded the support for that language.

Use this method to ask the Natural Language framework to load any missing assets for that tag scheme. This method returns immediately but the framework may need time to complete the request. When the framework completes the request, it notifies your app with the completionHandler you provided to the method. In your completion handler, use the result parameter to check whether the tag scheme is now available.

The Natural Language framework may call your completionHandler immediately if it knows the state of the tag scheme’s assets or if it experiences an error.

See Also

Getting the Tag Schemes

class func availableTagSchemes(for: NLTokenUnit, language: NLLanguage) -> [NLTagScheme]

Retrieves the tag schemes available for a particular unit (like word or sentence) and language on the current device.

enum NLTagger.AssetsResult

The response to an asset request.

var tagSchemes: [NLTagScheme]

The tag schemes configured for this linguistic tagger.

struct NLTagScheme

Constants for the tag schemes specified when initializing a linguistic tagger.