On Dec 14, 2008, at 12:30 PM, Yang Meyer wrote:

I am trying to enable dropping dragged iCal events onto my Cocoa application's icon, e.g. in the Dock.

While it was fairly straightforward to support ICS files that are dragged from the Finder (setting NSFilenamesPboardType with extension "ics" in the target's document types, and implementing - (BOOL)application:(NSApplication *)sender openFile:(NSString *)path in my application's delegate), I haven't been able to support iCal events that are dragged directly from iCal.

I analogously tried defining a document type for what I presume will be an NSFilesPromisePboardType, but I'm not sure what to put in the fields. Neither using extension "ics" nor MIME type "text/calendar" works. As for my NSFilenamesPboardType document type, I set the Store Type to "In memory".

So in essence my question is: How can I tell my application to accept iCal events dragged directly from the iCal GUI?

Hey Yang,

When iCal events are dragged and exported to another application, iCal will provide a promised .ics file in ~/Library/Caches/TemporaryItems. This file has an extension "ics" and a UTI of com.apple.ical.ics. Ideally, you'd just set the Document Types in your target's properties (Info.plist) to support this file, but it seems a bit tricky since this is a promised file and probably does not have these attributes set yet during the drag.

I didn't have a lot of time to experiment or research how to support promised file drops on the application icon, but one way to make this work is to register a "catch all" document type in Info.plist, and then your application will allow drops of iCal events, although along with it every other kind of file. You can do this in your target's properties window by adding a document type with an extension of "*" and an OS type of "****". You will now receive the temporary file "~Library/Caches/TemporaryItems/Event.ics" in your App delegate's application:openFile: method when an iCal event is dropped on your application's icon. You will have to make sure to look at the type of files in the delegate method now, since you will receive anything with the catch all type set.

Hope that helps,
Sean.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to