我使用下面的代码从代码更改键盘布局,但在第二行的警告下方发生。

//warning
Assigning to 'TISInputSourceRef' (aka 'struct __TISInputSource *') from 'const void *' discards qualifiers




//code
CFArrayRef sourceList = TISCreateInputSourceList (NULL, false);
TISInputSourceRef wantedSource= CFArrayGetValueAtIndex(sourceList, 0);
TISSelectInputSource(wantedSource);

最佳答案

我认为您需要转换CFArrayGetValueAtIndex类型为const void*的值:

TISInputSourceRef wantedSource = (TISInputSourceRef)CFArrayGetValueAtIndex(sourceList, 0);

关于objective-c - 从OSX中的代码更改键盘布局,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10750951/

10-12 21:44