Matt Gemmell

TOLL is available now!

An action-thriller novel — book 2 in the KESTREL series.

★★★★★ — Amazon

iCal Calendars source

development & source 1 min read

I posted a little code snippet I wrote when I was updating iCal Birthday Shifter recently; it reads the meta-data about iCal’s calendars and returns an NSDictionary of Calendar objects.

Extract from the Cocoa Source Code page:

A simple application which reads iCal's calendars and returns an NSDictionary whose keys are the names of the calendars, and whose values are Calendar objects, with fields "title" (NSString), "notes" (NSString), "color" (NSColor), and both GUID keys used by iCal to keep track of calendars and their source data.

Useful if you need a list of the user's iCal calendars with their names, descriptions and correct colors. This code parses the actual XML property list files which define the calendars; it doesn't use AppleScript, nor require launching iCal.

Note: this project requires Xcode 2.1 and Mac OS X 10.4 (Tiger) or later.

You can download it here (.tgz, 21k). Please note once again that the project requires Xcode 2.1 on Tiger, but you can readily add the source files to a new project in whatever version of Xcode you’re using.

Oh, and before anyone requests an actual Objective-C iCalendar parser… yeah, I’ll get right on that. Or just wrap libical, as I believe iCal itself does.