I'm trying to get an icon for an input source on macOS using
TISGetInputSourceProperty(inputSource, kTISPropertyIconRef)
It returns UnsafeMutableRawPointer
and I'm having trouble converting it to something that can be rendered in SwiftUI. The plan was to construct Data
from the raw pointer and then construct NSImage
, but to construct the former, I need a size of the bytes, which I don't have.
What would be the proper way to solve this?
I'm on swiftlang-5.7.2.135.5
.
You probably want this deprecated initializer on NSImage
if you're using IconRef
s: Apple Developer Documentation, you'd just cast the pointer to IconRef
since that's just a typealias of OpaquePointer
(Apple Developer Documentation)
I think it's more likely that you don't want to use IconRef
s at all, but I don't know the specifics of what you're doing, and I'm also not terribly familiar with TISGetInputSourceProperty
.
1 Like
Thanks! Yeah, I ditched this initializer since it is deprecated, but looks like it's the only way to get there.