Re: Accepting files dragged from iTunes in a Cocoa app
Excellent! Thanks a lot, this works well for me too.
I didn't know about the "CorePasteboardFlavorType" mechanism, and I
couldn't find any documentation about it, so I suppose this isn't
guaranteed to work in the future.
Best,
Stefan
Stephen F. Booth <[EMAIL PROTECTED]> wrote:
> Stefan,
>
> I use the following code to get the URLs from dragged files from iTunes:
>
> NSString * const iTunesPboardType = @"CorePasteboardFlavorType 0x6974756E";
>
> // Handle iTunes drops
> else if([bestType isEqualToString:iTunesPboardType]) {
> NSDictionary *iTunesDictionary = [[info draggingPasteboard]
> propertyListForType:iTunesPboardType];
> NSArray *tracks = [iTunesDictionary valueForKey:@"Tracks"];
> NSEnumerator *enumerator = [tracks objectEnumerator];
> NSDictionary *track = nil;
> NSURL *url = nil;
>
> while((track = [enumerator nextObject])) {
> url = [NSURL URLWithString:[track valueForKey:@"Location"]];
>
> if([url isFileURL])
> ; // Do something with URL
> }
> }
>
> Stephen
--
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/
___
Cocoa-dev mailing list ([email protected])
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 [EMAIL PROTECTED]
Re: Accepting files dragged from iTunes in a Cocoa app
Stefan,
I use the following code to get the URLs from dragged files from iTunes:
NSString * const iTunesPboardType = @"CorePasteboardFlavorType 0x6974756E";
// Handle iTunes drops
else if([bestType isEqualToString:iTunesPboardType]) {
NSDictionary *iTunesDictionary = [[info draggingPasteboard]
propertyListForType:iTunesPboardType];
NSArray *tracks = [iTunesDictionary valueForKey:@"Tracks"];
NSEnumerator *enumerator = [tracks objectEnumerator];
NSDictionary *track = nil;
NSURL *url = nil;
while((track = [enumerator nextObject])) {
url = [NSURL URLWithString:[track valueForKey:@"Location"]];
if([url isFileURL])
; // Do something with URL
}
}
Stephen
___
Cocoa-dev mailing list ([email protected])
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 [EMAIL PROTECTED]
Re: Accepting files dragged from iTunes in a Cocoa app
Stefan,
I use the following code to get the URLs from dragged files from iTunes:
NSString * const iTunesPboardType = @"CorePasteboardFlavorType 0x6974756E";
// Handle iTunes drops
else if([bestType isEqualToString:iTunesPboardType]) {
NSDictionary *iTunesDictionary = [[info draggingPasteboard]
propertyListForType:iTunesPboardType];
NSArray *tracks = [iTunesDictionary valueForKey:@"Tracks"];
NSEnumerator *enumerator = [tracks objectEnumerator];
NSDictionary *track = nil;
NSURL *url = nil;
while((track = [enumerator nextObject])) {
url = [NSURL URLWithString:[track valueForKey:@"Location"]];
if([url isFileURL])
; // Do something with URL
}
}
Stephen
___
Cocoa-dev mailing list ([email protected])
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 [EMAIL PROTECTED]
Re: Accepting files dragged from iTunes in a Cocoa app
Gregory Weston <[EMAIL PROTECTED]> wrote: > Stefan Haller wrote: > > > In a Carbon application I solved the problem by handling the > > kDragPromisedFlavorFindFile flavor, which worked quite well. How do I > > do this in a Cocoa app though? I can't find any NS*PboardType that > > seems to relate to it. > > I think you want to have a look at Tech Note 1085 developer.apple.com/technotes/tn/tn1085.html>. It looks like iTunes > is mimics the behavior of Find File described in there. I'm pretty familiar with the mechanisms from that tech note; I just don't know how to do this in *Cocoa*; that's why I was posting to this list, not to carbon-dev. Best, Stefan -- Stefan Haller Berlin, Germany http://www.haller-berlin.de/ ___ Cocoa-dev mailing list ([email protected]) 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 [EMAIL PROTECTED]
Re: Accepting files dragged from iTunes in a Cocoa app
Stefan Haller wrote: When dragging files from iTunes, iTunes sends the following drag flavors (according to DragPeeker X): phfs (kDragFlavorTypePromiseHFS) rWm1 (kDragPromisedFlavorFindFile) Hpfl itun I can't find any reference to the last two on the web, so I assume they are private flavors. In a Carbon application I solved the problem by handling the kDragPromisedFlavorFindFile flavor, which worked quite well. How do I do this in a Cocoa app though? I can't find any NS*PboardType that seems to relate to it. Accepting the file promise is not what I want; I don't want to create a new file, but reference the existing file in the iTunes library. Any ideas? I think you want to have a look at Tech Note 1085 developer.apple.com/technotes/tn/tn1085.html>. It looks like iTunes is mimics the behavior of Find File described in there. Which kinda- sorta makes sense. Find File and that tech note established and then documented a mechanism by which query results can be dragged, and iTunes' file manipulation does kind of fall under the umbrella of (updateable) queries rather than being a first class file system in its own right. ___ Cocoa-dev mailing list ([email protected]) 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 [EMAIL PROTECTED]
