Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Cocoa script for getting definitions of words
int main(int argc, const char * argv[])
{
@autoreleasepool {
if (argc == 1) {
return 1;
}
NSString *word = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding];
CFStringRef result = DCSCopyTextDefinition(nil, (__bridge CFStringRef)word, CFRangeMake(0, word.length));
NSString *definition = (__bridge NSString *)result;
const char *cDefinition = [definition cStringUsingEncoding:NSUTF8StringEncoding];
printf("%s", cDefinition);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment