I am working on OSX, Xcode 8.2. Objective-C. I use scripting bridge to adress Adobe InDesign. I have a pretty long AppleScript i want to translate to Objective-C with Scripting-Bridge to take advantage of its background-task possibilities.
For better understanding let me show you the part from applescript before:
tell application "Adobe InDesign CC 2017"
tell active document
-- grep setup done before
find grep
end tell
end tell
The result in applescript:
{
text from character 294 to character 298 of story id 1354 of document id 5 of application "Adobe InDesign CC 2017",
text from character 140 to character 144 of story id 1377 of document id 5 of application "Adobe InDesign CC 2017"
}
If i want to get the string in applescript i perform (notice the "as string"):
text from character 294 to character 298 of story id 1354 of document id 5 of
application "Adobe InDesign CC 2017" as string
--> "Test1"
The translated method in objective-c:
// document is an instance of the SBApplication indesign
[document findGrepReverseOrder:NO];
The result reads:
(
"<AdobeInDesignCC2017TextCtxt @0x608020a442f0: AdobeInDesignCC2017TextCtxt [<NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'from':'obj '{ 'form':'ID ', 'from':'obj '{ 'form':'ID ', 'from':null(), 'seld':5, 'want':'docu' }, 'seld':1354, 'want':'cflo' }, 'seld':294, 'want':'cha ' }>..<NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'from':'obj '{ 'form':'ID ', 'from':'obj '{ 'form':'ID ', 'from':null(), 'seld':5, 'want':'docu' }, 'seld':1354, 'want':'cflo' }, 'seld':298, 'want':'cha ' }>] of AdobeInDesignCC2017Story id 1354 of AdobeInDesignCC2017Document id 5 of application \"Adobe InDesign CC 2017\" (696)>",
"<AdobeInDesignCC2017TextCtxt @0x608020a44140: AdobeInDesignCC2017TextCtxt [<NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'from':'obj '{ 'form':'ID ', 'from':'obj '{ 'form':'ID ', 'from':null(), 'seld':5, 'want':'docu' }, 'seld':1377, 'want':'cflo' }, 'seld':140, 'want':'cha ' }>..<NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'from':'obj '{ 'form':'ID ', 'from':'obj '{ 'form':'ID ', 'from':null(), 'seld':5, 'want':'docu' }, 'seld':1377, 'want':'cflo' }, 'seld':144, 'want':'cha ' }>] of AdobeInDesignCC2017Story id 1377 of AdobeInDesignCC2017Document id 5 of application \"Adobe InDesign CC 2017\" (696)>"
)
It looks like each AdobeInDesignCC2017TextCtxt object contains two appleeventdescriptors to mark the position of the word and the length. I need to access them to extract the information. I checked the h. file but cannot find a method to extract the text like in applescript with "as string". How can i access the descriptors? Any idea appreciated.