- Storing Secrets
- The Address Book
- Calendar Services
- Other APIs
The calendar services API is the most modern of the three that I've covered in this article. It was introduced with OS X 10.5 and so uses a lot of features to simplify the code.
The first thing that you'll notice about the calendar API is that it uses declared properties everywhere. A lot of the classes don't declare any methods, just properties. Of course, declared properties are implemented by message sending, so setting some of these may cause complex methods to be called, but this is all hidden from you.
Using the calendar services API is very simple. Unlike the address book, it uses standard collections where possible and supports fast enumeration for iterating over them.
The three basic objects the API exposes are events, to-do items, and calendars. The first two of these are contained within the former. Creating new calendar items is as simple as creating the relevant objects and associating them with a calendar.
Unlike the address book, you can search calendars using NSPredicates, just as you search anything else. Searches return array of elements and you can iterate over these just as you would any other NSArray.
The calendar store API doesn't just use local calendars. It also supports remote calendars stored on WebDAV or CalDAV servers, and with 10.6 also supports Microsoft Exchange shared calendars. This highlights one of the advantages of using built-in frameworks. If you wrote an application using the calendar store API on an earlier version of OS X, then your users would have got Exchange integration for free when they upgraded to Snow Leopard.