从osx中的代码更改键盘布局

时间:2012-05-25 08:20:40

标签: objective-c cocoa

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

//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);

1 个答案:

答案 0 :(得分:0)

我认为您需要转换CFArrayGetValueAtIndex返回的值,其类型为const void*

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