Using AVAsynchronousKeyValueLoading in Swift


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?



The solution was #keyPath. I for some reason thought that KeyPath had replaced #keyPath in Swift, but #keyPath(AVAsset. availableMediaCharacteristicsWithMediaSelectionOptions) gives the string "availableMediaCharacteristicsWithMediaSelectionOptions" which is exactly what I want.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

佛陀 (漫畫)

Đế Bá

文学批评