2

プロパティ リスト ファイル (.plist) の RecentApplication > 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

次のようなエラーが表示されます。

「システム イベントでエラーが発生しました: プロパティ リスト アイテム \"名前\" のすべてのテキストを作成できません (プロパティ リスト アイテム \"RecentApplications\" のプロパティ リスト アイテム \"RecentApplications\" の内容のプロパティ リスト アイテム] \"Macintosh HD:Users:craibuc:Library:Preferences:com.apple.recentitems.plist\") を文字列型に変換します。" プロパティリスト項目のすべてのテキストから数 -1700 プロパティリスト項目の「Name」(プロパティリスト項目の「CustomListItems」プロパティリスト項目の「RecentApplications」プロパティリストファイルの内容「Macintosh HD:Users:craibuc:Library:Preferences:com」 .apple.recentitems.plist") を文字列に

さらに、コードを次のように変更すると:

  repeat with i from 1 to number of items in itemNodes

    display dialog i

  end repeat

単一のダイアログが表示されます。つまり、配列自体を調べているようには見えません。

PLI の配列をキャプチャする正しい方法は何ですか?

4

1 に答える 1

3

正しい構文は次のとおりです。

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

「のプロパティ リスト項目」を追加する必要がありました。

于 2011-02-18T16:04:36.223 に答える