我使用下面的代码从代码更改键盘布局,但在第二行的警告下面发生。
//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);
答案 0 :(得分:0)
我认为您需要转换CFArrayGetValueAtIndex
返回的值,其类型为const void*
:
TISInputSourceRef wantedSource = (TISInputSourceRef)CFArrayGetValueAtIndex(sourceList, 0);