Skip to content

Instantly share code, notes, and snippets.

@maxgribov
Last active August 11, 2016 20:20
Show Gist options
  • Save maxgribov/e366c88dd5e0ee359925552faf6e0e83 to your computer and use it in GitHub Desktop.
Save maxgribov/e366c88dd5e0ee359925552faf6e0e83 to your computer and use it in GitHub Desktop.
Print Mac OS X Text Input Source Services
/*
#import <Carbon/Carbon.h>
*/
- (void)printInputSources {
CFArrayRef sourceList = TISCreateInputSourceList (NULL, true);
int sourceCount = CFArrayGetCount(sourceList);
for (int i = 0; i < sourceCount; i++) {
NSMutableDictionary *property = [NSMutableDictionary dictionary];
[property setObject:(__bridge id _Nonnull)(TISGetInputSourceProperty(CFArrayGetValueAtIndex(sourceList, i), kTISPropertyLocalizedName)) forKey:@"kTISPropertyLocalizedName"];
[property setObject:(__bridge id _Nonnull)(TISGetInputSourceProperty(CFArrayGetValueAtIndex(sourceList, i), kTISPropertyInputSourceType)) forKey:@"kTISPropertyInputSourceType"];
[property setObject:(__bridge id _Nonnull)(TISGetInputSourceProperty(CFArrayGetValueAtIndex(sourceList, i), kTISPropertyInputSourceID)) forKey:@"kTISPropertyInputSourceID"];
[property setObject:(__bridge id _Nonnull)(TISGetInputSourceProperty(CFArrayGetValueAtIndex(sourceList, i), kTISPropertyLocalizedName)) forKey:@"kTISPropertyLocalizedName"];
NSLog(@"%@", property);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment