From: Craig W. <cwi...@ma...> - 2008-08-19 15:53:53
|
A friend of mine wrote a Python script to access the DictionaryServices framework. It was a little slow so I wrote one in Ruby and Obj-C to compare. With Ruby I am getting the error as shown below. Any suggestions as to what I am missing here? Toda, (thanks) Craig Obj-C code that works: NSString *searchword = [args objectAtIndex:1]; CFRange range = CFRangeMake(0, [searchword length]); CFStringRef def = DCSCopyTextDefinition(NULL, searchword, range); Python code that works: searchword = sys.argv[1].decode('utf-8') wordrange = (0, len(searchword)) dictresult = DCSCopyTextDefinition(None, searchword, wordrange) Ruby code: word = 'History' # also tried as NSString word_len = NSRange.new(0, word.length) # also tried as CFRange puts DCSCopyTextDefinition(nil, word, word_len) The error: OSX::OCDataConvException: Cannot convert the argument #2 as '{?=ii}' to Objective-C Frameworks: require 'osx/cocoa'; include OSX require_framework '/System/Library/Frameworks/CoreServices.framework/ Frameworks/DictionaryServices.framework' DictionaryServices would not load without the full path. |