解析 AppleScriptObjC 中的 NSAppleEventDescriptor
Parse NSAppleEventDescriptor in AppleScriptObjC
我正在尝试为 Automator 编写一个 AppleScript 应用程序来操作联系人组。我收到了一个联系人项目作为脚本的输入,但我不知道如何解析它。这是我到目前为止写的来源:
script Labels_for_contact_groups
property parent : class "AMBundleAction"
on runWithInput_fromAction_error_(input, anAction, errorRef)
-- Get parameters
set labelName to valueForKey_("trainingLabelName") of parameters() of me
set labelValue to valueForKey_("trainingLabelValue") of parameters() of me
-- Iterate over the contact groups
-- what should I do here?
log input
return input
end runWithInput_fromAction_error_
end script
我在日志中得到以下信息:
2016-10-12 11:35:28.061 Automator[2167:174553] <NSAppleEventDescriptor: [ 'obj '{ 'want':'azf5', 'form':'ID ', 'seld':'utxt'("50E8C441-3DF0-4CD7-8E36-E175B37D2CCB:ABGroup"), 'from':[0x0,10d10d "Contacts"] } ]>
我需要做的是提取指定群组中所有联系人的信息。我该如何进行?
编辑:
我添加了以下行
tell application "Contacts" to set thePeople to people of input
repeat with i from 1 to number of items in thePeople
set thisPersonCurrent to item i of thePeople
log thisPersonCurrent
end repeat
现在我得到以下错误:
[Labels_for_contact_groups runWithInput:fromAction:error:]: Can’t get every «class azf4» of «class ocid» id «data optr0000000080A9220080600000». (error -1728)
我做错了什么?
我试图实现的目标无法通过 Automator 实现。我意识到 API 中存在许多空白。最终起作用的是带有以下行的独立 AppleScript:
tell application "Contacts"
set theGroupNames to name of groups
set text_returnedCurrent to choose from list theGroupNames with prompt "Select Group" without multiple selections allowed
set the_peopleCurrent to people of group (text_returnedCurrent as text)
...
我正在尝试为 Automator 编写一个 AppleScript 应用程序来操作联系人组。我收到了一个联系人项目作为脚本的输入,但我不知道如何解析它。这是我到目前为止写的来源:
script Labels_for_contact_groups
property parent : class "AMBundleAction"
on runWithInput_fromAction_error_(input, anAction, errorRef)
-- Get parameters
set labelName to valueForKey_("trainingLabelName") of parameters() of me
set labelValue to valueForKey_("trainingLabelValue") of parameters() of me
-- Iterate over the contact groups
-- what should I do here?
log input
return input
end runWithInput_fromAction_error_
end script
我在日志中得到以下信息:
2016-10-12 11:35:28.061 Automator[2167:174553] <NSAppleEventDescriptor: [ 'obj '{ 'want':'azf5', 'form':'ID ', 'seld':'utxt'("50E8C441-3DF0-4CD7-8E36-E175B37D2CCB:ABGroup"), 'from':[0x0,10d10d "Contacts"] } ]>
我需要做的是提取指定群组中所有联系人的信息。我该如何进行?
编辑: 我添加了以下行
tell application "Contacts" to set thePeople to people of input
repeat with i from 1 to number of items in thePeople
set thisPersonCurrent to item i of thePeople
log thisPersonCurrent
end repeat
现在我得到以下错误:
[Labels_for_contact_groups runWithInput:fromAction:error:]: Can’t get every «class azf4» of «class ocid» id «data optr0000000080A9220080600000». (error -1728)
我做错了什么?
我试图实现的目标无法通过 Automator 实现。我意识到 API 中存在许多空白。最终起作用的是带有以下行的独立 AppleScript:
tell application "Contacts"
set theGroupNames to name of groups
set text_returnedCurrent to choose from list theGroupNames with prompt "Select Group" without multiple selections allowed
set the_peopleCurrent to people of group (text_returnedCurrent as text)
...