1

I'm trying to write an AppleScript that simply iterates over uncompleted Reminders and displays the name. The code below generates this error: Reminders got an error: Can’t make name of reminder (reminder id \"x-apple-reminder://838D4BDF-C520-440A-ADF2-B66FD602ADDC\") into type string

I figured out how to make it work by iterating from 1 to (count of notCompleted); but I would like to understand why the code below doesn't work. (The fact that I expect the code below to work suggests that I am misunderstanding what kind of objects are in notCompleted.) What exactly is contained in notCompleted, and what exactly is the type of currentReminder?

tell application "Reminders"
    set snoozeList to "Snooze"
    set notCompleted to reminders in list snoozeList whose completed is false
    repeat with currentReminder in notCompleted
        display dialog (name of reminder currentReminder)
    end repeat
end tell
1

Your understanding seems on point, apart from two small items. As you already know, notCompleted contains a list of reminders that are not completed. The variable currentReminder in each iteration of the repeat loop will therefore contain a single reminder object. Therefore, firstly, you don't need to (or rather, you ought not to) use the reminder specifier in name of reminder currentReminder. Instead, just use name of currentReminder.

This doesn't entirely solve the issue as the name of currentReminder is returned in a partially de-referenced format (which is something I won't go in to here, but is a consequence of how the items are enumerated under the hood). This means that to access the actual text data, you either have to coerce it to text like so:

display dialog (name of currentReminder as text)

or use the get command, which basically does the same thing:

display dialog (get name of currentReminder)

So it's nothing that you're doing wrong in a strict sense, just quirks of AppleScript.

  • That was it. I hadn't heard of "as text" or "get". Can you recommend a document or two that explains some of AppleScript's quirks? – Zack Dec 28 '18 at 15:05
  • Not it’s quirks, no, they are something you get used to through experience. But if you haven’t heard of as text, you’ll want to start with the Apple Developer documentation on the different data types, coercions, and such. I’ll find the link for you and post it. – CJK Dec 29 '18 at 12:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .