Use typed unretained cast for input source ID

This commit is contained in:
Lawrence Chen 2026-02-25 02:45:55 -08:00
parent b6c5e3fe9e
commit a0d2bca45d

View file

@ -5,7 +5,7 @@ class KeyboardLayout {
static var id: String? {
if let source = TISCopyCurrentKeyboardInputSource()?.takeRetainedValue(),
let sourceIdPointer = TISGetInputSourceProperty(source, kTISPropertyInputSourceID) {
let sourceId = unsafeBitCast(sourceIdPointer, to: CFString.self)
let sourceId = Unmanaged<CFString>.fromOpaque(sourceIdPointer).takeUnretainedValue()
return sourceId as String
}