Cast from UnsafePointer to UCKeyboardLayout *
// CFData.h
CF_EXPORT
const UInt8 *CFDataGetBytePtr(CFDataRef theData);
// UnicodeUtilitiees.h
extern OSStatus
UCKeyTranslate(
const UCKeyboardLayout * keyLayoutPtr,
UInt16 virtualKeyCode,
UInt16 keyAction,
UInt32 modifierKeyState,
UInt32 keyboardType,
OptionBits keyTranslateOptions,
UInt32 * deadKeyState,
UniCharCount maxStringLength,
UniCharCount * actualStringLength,
UniChar unicodeString[]) __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA);
let layoutData = CFDataGetBytePtr(layoutDataRef)
// let layoutDataPtr = UnsafePointer<UCKeyboardLayout>(layoutData)
var length = 0
let layoutChars: [UniChar] = [0] as [UniChar]
var deadKeyState: UInt32 = 0
error = UCKeyTranslate(layoutData, UInt16(keyCode), kUCKeyActionDisplay, 0, // No modifiers
LMGetKbdType(), kUCKeyTranslateNoDeadKeysMask, &deadKeyState, MemoryLayout<UniChar>.size / MemoryLayout<UniChar>.size, &length, layoutChars)