MLKitCommon Framework Reference

  • ModelDownloadConditions configures how a machine learning model is downloaded, including network and background preferences.

  • By default, models can be downloaded over cellular networks but not in the background.

  • You can customize these settings when creating a ModelDownloadConditions instance, specifying whether to allow cellular access and background downloading.

  • The init() initializer creates an instance with default settings, while the designated initializer lets you customize the download conditions.

ModelDownloadConditions

class ModelDownloadConditions : NSObject, NSCopying

Configurations for model downloading conditions.

  • Indicates whether download requests should be made over a cellular network. The default is YES.

    Declaration

    Swift

    var allowsCellularAccess: Bool { get }
  • Indicates whether the model can be downloaded while the app is in the background. The default is NO.

    Declaration

    Swift

    var allowsBackgroundDownloading: Bool { get }
  • Creates a new instance with the given conditions.

    Declaration

    Swift

    init(allowsCellularAccess: Bool, allowsBackgroundDownloading: Bool)

    Parameters

    allowsCellularAccess

    Whether download requests should be made over a cellular network.

    allowsBackgroundDownloading

    Whether the model can be downloaded while the app is in the background.

    Return Value

    A new ModelDownloadConditions instance.

  • Creates a new instance with the default conditions. The default values are specified in the documentation for each instance property.

    Declaration

    Swift

    convenience init()

    Return Value

    A new ModelDownloadConditions instance.