Skip to content

Instantly share code, notes, and snippets.

@swdyh
Created September 8, 2011 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swdyh/1203094 to your computer and use it in GitHub Desktop.
Save swdyh/1203094 to your computer and use it in GitHub Desktop.
#import <Cocoa/Cocoa.h>
#import <CoreServices/CoreServices.h>
int main(int argc, char *argv[])
{
NSString *word;
NSString *result;
if (argc > 1) {
word = [[NSString alloc] initWithUTF8String:argv[1]];
result = (NSString *)DCSCopyTextDefinition(NULL, (CFStringRef)word, CFRangeMake(0, [word length]));
// NSLog(@"word: %@", word);
// NSLog(@"result: %@", result);
if (result) {
printf("%s", [result UTF8String]);
return 0;
}
}
return 1;
}
all:
gcc -o dict -Wall -fobjc-gc -O2 -std=c99 dict.m -framework carbon -framework cocoa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment