MLKitCommon Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
MLKModelManager
@interface
MLKModelManager
:
NSObject
Manages models that are used by MLKit features.
-
Returns a ModelManager
instance.
Declaration
Objective-C
+
(
nonnull
instancetype
)
modelManager
;
Return Value
A ModelManager
instance.
-
Unavailable. Use the modelManager()
class method.
Declaration
Objective-C
-
(
nonnull
instancetype
)
init
;
-
Checks whether the given model has been downloaded.
Declaration
Objective-C
-
(
BOOL
)
isModelDownloaded
:(
nonnull
MLKRemoteModel
*
)
remoteModel
;
Parameters
remoteModel
The model to check the download status for.
Return Value
Whether the given model has been downloaded.
-
Downloads the given model from the server to a local directory on the device. Use isModelDownloaded(_:)
to check the download status for the model. If this method is invoked and
the model has already been downloaded, a request is made to check if a newer version of the model
is available for download. If available, the new version of the model is downloaded.
To know when this method is done, observe the .mlkitModelDownloadDidSucceed
and .mlkitModelDownloadDidFail
notifications defined in MLKModelDownloadNotifications.h
.
If the latest model is already downloaded, completes without additional work and posts .mlkitModelDownloadDidSucceed
notification, indicating that the model is ready to use.
Parameters
remoteModel
|
|
conditions
|
The conditions for downloading the model.
|
Return Value
Progress for downloading the model.
-
Deletes the downloaded model from the device.
Declaration
Objective-C
-
(
void
)
deleteDownloadedModel
:(
nonnull
MLKRemoteModel
*
)
remoteModel
completion
:(
nonnull
void
(
^
)(
NSError
*
_Nullable
))
completion
;
Parameters
remoteModel
|
The downloaded model to delete.
|
completion
|
Handler to call back on the main queue when the model deletion completed
successfully or failed with the given error
.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eMLKModelManager\u003c/code\u003e class in MLKit manages the downloading, checking, and deletion of machine learning models.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003edownloadModel:conditions:\u003c/code\u003e to download a specified model, and \u003ccode\u003eisModelDownloaded:\u003c/code\u003e to confirm its download status.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003edeleteDownloadedModel:completion:\u003c/code\u003e facilitates the removal of a downloaded model from the local device.\u003c/p\u003e\n"],["\u003cp\u003eTo get an instance of \u003ccode\u003eMLKModelManager\u003c/code\u003e, use the static method \u003ccode\u003emodelManager()\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# MLKitCommon Framework Reference\n\nMLKModelManager\n===============\n\n\n @interface MLKModelManager : NSObject\n\nManages models that are used by MLKit features.\n- `\n ``\n ``\n `\n\n ### [+modelManager](#/c:objc(cs)MLKModelManager(cm)modelManager)\n\n `\n ` \n Returns a `ModelManager` instance. \n\n #### Declaration\n\n Objective-C \n\n + (nonnull instancetype)modelManager;\n\n #### Return Value\n\n A `ModelManager` instance.\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)MLKModelManager(im)init)\n\n `\n ` \n Unavailable. Use the `modelManager()` class method. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull instancetype)init;\n\n- `\n ``\n ``\n `\n\n ### [-isModelDownloaded:](#/c:objc(cs)MLKModelManager(im)isModelDownloaded:)\n\n `\n ` \n Checks whether the given model has been downloaded. \n\n #### Declaration\n\n Objective-C \n\n - (BOOL)isModelDownloaded:(nonnull ../Classes/MLKRemoteModel.html *)remoteModel;\n\n #### Parameters\n\n |---------------------|---------------------------------------------|\n | ` `*remoteModel*` ` | The model to check the download status for. |\n\n #### Return Value\n\n Whether the given model has been downloaded.\n- `\n ``\n ``\n `\n\n ### [-downloadModel:conditions:](#/c:objc(cs)MLKModelManager(im)downloadModel:conditions:)\n\n `\n ` \n Downloads the given model from the server to a local directory on the device. Use\n `isModelDownloaded(_:)` to check the download status for the model. If this method is invoked and\n the model has already been downloaded, a request is made to check if a newer version of the model\n is available for download. If available, the new version of the model is downloaded.\n\n To know when this method is done, observe the `.mlkitModelDownloadDidSucceed` and\n `.mlkitModelDownloadDidFail` notifications defined in `MLKModelDownloadNotifications.h`.\n If the latest model is already downloaded, completes without additional work and posts\n `.mlkitModelDownloadDidSucceed` notification, indicating that the model is ready to use. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull NSProgress *)downloadModel:(nonnull ../Classes/MLKRemoteModel.html *)remoteModel\n conditions:\n (nonnull ../Classes/MLKModelDownloadConditions.html *)conditions;\n\n #### Parameters\n\n |---------------------|-------------------------------------------|\n | ` `*remoteModel*` ` | The model to download. |\n | ` `*conditions*` ` | The conditions for downloading the model. |\n\n #### Return Value\n\n Progress for downloading the model.\n- `\n ``\n ``\n `\n\n ### [-deleteDownloadedModel:completion:](#/c:objc(cs)MLKModelManager(im)deleteDownloadedModel:completion:)\n\n `\n ` \n Deletes the downloaded model from the device. \n\n #### Declaration\n\n Objective-C \n\n - (void)deleteDownloadedModel:(nonnull ../Classes/MLKRemoteModel.html *)remoteModel\n completion:(nonnull void (^)(NSError *_Nullable))completion;\n\n #### Parameters\n\n |---------------------|-------------------------------------------------------------------------------------------------------------------------|\n | ` `*remoteModel*` ` | The downloaded model to delete. |\n | ` `*completion*` ` | Handler to call back on the main queue when the model deletion completed successfully or failed with the given `error`. |"]]