Instance Method


Tells the asset to load the values of all of the specified keys (property names) that are not already loaded.



- (void)loadValuesAsynchronouslyForKeys:(NSArray<NSString *> *)keys completionHandler:(void (^)(void))handler;



An array of strings containing the required keys.

The keys are the property names of a class that adopts the protocol.


The block to be invoked when loading succeeds, fails, or is cancelled.


Regardless of the number of keys specified, the completion handler will be invoked exactly once per invocation of this method. This method will be called:

  • Synchronously if all specified keys have previously been loaded (a status of AVKeyValueStatusLoaded) or if an I/O error or other format-related error occurs immediately.

  • Asynchronously when the values of all of the specified keys become loaded, if a loading error occurs at a later stage of processing, or if cancelLoading is invoked on an AVAsset instance. The callback will be invoked on an arbitrary background queue. You should dispatch back to the main queue before performing any user interface-related operations.

The completion states of the keys you specify in keys are not necessarily the same—some may be loaded, and others may have failed. You must check the status of each key individually using the statusOfValueForKey:error: method.

You can call this method at any time, even after an asset has begun to load data for operations in progress or already completed. Whenever any module requires a certain collection of key-values, it can call this method and be assured of receiving its specified callback as soon as possible.

The following example shows how to use this method to load an asset’s playable key:

// Load the asset's "playable" key
[asset loadValuesAsynchronouslyForKeys:@[@"playable"] completionHandler:^{
    NSError *error = nil;
    AVKeyValueStatus status =
        [asset statusOfValueForKey:@"playable" error:&error];
    switch (status) {
        case AVKeyValueStatusLoaded:
            // Sucessfully loaded, continue processing
        case AVKeyValueStatusFailed:
            // Examine NSError pointer to determine failure
        case AVKeyValueStatusCancelled:
            // Loading cancelled
            // Handle all other cases

See Also

Loading Assets by Key

- statusOfValueForKey:error:

Returns a status indicating whether the value for a given key is immediately available without blocking the calling thread.


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software