Skip to content

Instantly share code, notes, and snippets.

@vojto
Created October 25, 2012 17:41
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vojto/3954249 to your computer and use it in GitHub Desktop.
Save vojto/3954249 to your computer and use it in GitHub Desktop.
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