I'm curious if there is a Swifty, safe way to use AVAsynchronousKeyValueLoading
without having to hard code the keys I'm using. Specifically, I'd like to call loadValuesAsynchronously(forKeys:completionHandler:)
with the key "availableMdiaCharacteristicsWithMediaSelectionOptions"
, but it currently isn't possible to get a String
from any kind of KeyPath
-based solution. I would love it if there was some kind of way to retrieve the name of a property in such a way that it would be checked at compile time whether the property exists. Is there such an API?
Using AVAsynchronousKeyValueLoading in Swift
283 views Asked by Jumhyn At
1
The solution was
#keyPath
. I for some reason thought thatKeyPath
had replaced#keyPath
in Swift, but#keyPath(AVAsset. availableMediaCharacteristicsWithMediaSelectionOptions)
gives the string"availableMediaCharacteristicsWithMediaSelectionOptions"
which is exactly what I want.