Created
October 25, 2012 17:41
-
-
Save vojto/3954249 to your computer and use it in GitHub Desktop.
Cocoa script for getting definitions of words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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