Apologies if this is something that's already possible or planned, but my initial searches turned up nothing. The AVAsynchronousKeyValueLoading
protocol provides a method for loading certain values on AVFoundation objects via the loadValuesAsynchronously(forKeys:completionHandler:)
method. Unfortunately, the keys
parameter is of type [String]
, and so does not support any nice KeyPath
Swiftiness. I'm curious if there is a plan for or a method to do either of the following:
-
Turn a property name into a string so that typos could be caught at compile time. For example, calling this method with the key
"availableMdiaCharacteristicsWithMediaSelectionOptions"
on anAVAsset
seems pretty gross even if the API is unlikely to change. -
Indicate in an Objective-C API that an
NSString *
parameter should (or array ofNSStrings
) should actually be treated as an (array of)KeyPath
objects.
Are there technical limitations to either of these that make them undesirable to pursue? What is the "Swifty" way to use the AVAsynchronousKeyValueLoading
API?