• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Should I use Sync Services?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should I use Sync Services?


  • Subject: Re: Should I use Sync Services?
  • From: Ben Kazez <email@hidden>
  • Date: Fri, 7 Apr 2006 18:10:50 -0500

On Apr 7, 2006, at 21:35:57 +0100, Mike Abdullah wrote:

Thanks for the info (and to Marcus Zarra as well).  I had no idea
before setting out whether Sync Services supported colours so I will
stick with parsing the nodes.plist.

I do intend to get hold of events themselves at some point in the
distant future, so I will look into Sync Services again then.

When you say it doesn't handle recurring events, what exactly do you
mean?  Will I simply not see any events other than the first one, or
will I see them but not know that they are recurring?

You'll get one entry for each event, no matter how many recurrences. Inside that entry will be information about how the event repeats. The calendar schema's recurrence properties are documented here:


<http://developer.apple.com/documentation/AppleApplications/Reference/ SyncServicesSchemaRef/Articles/Calendars.html#//apple_ref/doc/uid/ TP40001540-174926G>

They're based on the iCalendar RFC, which may also be helpful:

<http://www.ietf.org/rfc/rfc2445.txt>

Oh, and could I have a look at your code :)
I can do titles no problem, but I'm not really sure with the colours!

I took a look just now and realized that my code may not be that helpful, because I do the color handling from JavaScript (it's a Dashboard widget, so the hex color was more helpful than NSColor). But here's some Cocoa to load the calendars from nodes.plist:


NSString *iCalSupportDirectory = [NSHomeDirectory() stringByAppendingString:@"/Library/Application Support/iCal"];
NSString *nodesPath = [NSString stringWithFormat:@"%@/nodes.plist", iCalSupportDirectory];
NSArray *nodes = [[NSDictionary dictionaryWithContentsOfFile:nodesPath] objectForKey:@"List"];


My app doesn't need the group structure in nodes.plist, so I go through array of nodes and "flatten" out the groups into the root group. I also delete any calendars that don't have corresponding Sources/Info.plist or Sources/*.ics files, or titles.

For colors, if you chop off the last two characters of what in nodes.plist, you'll get a hexadecimal color familiar to web developers (#6197DEFF => #6197DE). For my app, I actually wanted this format, so I lazily left it as is. If you need an NSColor, you can split the hex into three groups of two digits, convert each group to decimal, divide by 255, and pass this triple to one of the NSColor init methods. If you need to display the calendar colors as colored rectangles (as in iCal's printed calendars), you'll want to truncate the color to #e6e6e6 (230/255, 230/255, 230/255) if its average RGB value is greater than this. This ensures that it will show up against a white background.

And finally, note that the Birthdays calendar is not stored as a calendar file; it is dynamically retrieved from Address Book. So if you need to support the Birthdays calendar, you'll need to retrieve this "manually" using AddressBook.framework.

Ben
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Newbie Question about using selected file name with fopen
  • Next by Date: Getting NSData out of an NSImage
  • Previous by thread: Re: Should I use Sync Services?
  • Next by thread: Leaks in NSImage's drawInRect:fromRect:operation:fraction:
  • Index(es):
    • Date
    • Thread