gpt4 book ai didi

arrays - 使用 AppleScript 枚举属性列表项数组

转载 作者:行者123 更新时间:2023-12-04 06:34:01 26 4
gpt4 key购买 nike

我正在尝试枚举属性列表文件 (.plist) 的最新应用程序 > CustomListItems 属性列表项的数组,但在语法上有一些困难:

tell application "System Events"

set the plist_path to "~/Library/Preferences/com.apple.recentitems.plist"
set the plist_file to property list file plist_path

set itemNodes to property list item "CustomListItems" of property list item "RecentApplications" of plist_file

repeat with i from 1 to number of items in itemNodes

set itemNode to item i of itemNodes

display dialog text of property list item "Name" of property list item itemNode

end repeat

end tell

我收到一条错误消息:

"System Events got an error: Can’t make every text of property list item \"Name\" of property list item (property list item \"CustomListItems\" of property list item \"RecentApplications\" of contents of property list file \"Macintosh HD:Users:craibuc:Library:Preferences:com.apple.recentitems.plist\") into type string." number -1700 from every text of property list item "Name" of property list item (property list item "CustomListItems" of property list item "RecentApplications" of contents of property list file "Macintosh HD:Users:craibuc:Library:Preferences:com.apple.recentitems.plist") to string



此外,如果我将代码更改为:
  repeat with i from 1 to number of items in itemNodes

display dialog i

end repeat

我得到一个对话框。换句话说,它似乎不是在检查数组本身。

捕获 PLI 数组的正确方法是什么?

最佳答案

正确的语法是:

set itemNodes to property list items of property list item "CustomListItems" of property list item "RecentApplications" of plist_file

我需要添加“属性列表项”。

关于arrays - 使用 AppleScript 枚举属性列表项数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5043218/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com