On Thu, Dec 18, 2008 at 2:09 PM, JongAm Park
<joshua_park2006-applel...@yahoo.com> wrote:
> Hello, all.
>
> I'm struggling to enable drag&dropping to Final Cut Pro's project window
> from my application.
>
> While I was trying to figure out how to, I found this strange thing.
>
> NSArray *supportedTypes = [NSArray
> arrayWithObject:NSFileContentsPboardType];
>
> NSString *matchingType = [pboard availableTypeFromArray:supportedTypes];
> if( [matchingType compare:@"NSFileContentsPboardType] == NSOrderedSame )
> {
>   outputFileName = [NSString stringWithFormat:@"%@/Desktop/test.mov",
> NSHomeDirectory()];
>   outputFileNameResult = [pboard
> readFileContentsType:NSFileContentsPboardType toFile:outputFileName];
> }
> ....
>
> I expected that the matchingType returned by calling availableTypeFromArray
> is @"NSFileContentsPboardType".
> But, in fact, it returns @"NXFileContentsPboardType".
> So, it doesn't reach the body of the if clause.
> Is this a bug?

It's a bug in your code.

Cocoa defines a string constant called NSFileContentsPboardType.
You're using a constant string with the *contents*
@"NSFileContentsPboardType". This is *not* the same thing. Nothing
says that the string constant must contain a string which exactly
matches its name. And in this case, it doesn't match. Use
NSFileContentsPboardType instead of @"NSFileContentsPboardType" and
you'll find your code will suddenly work. Any time the actual content
of a string constant is not documented, you *must* only use the
constant itself in your code, not what it contains (or what you think
it contains).

Mike
_______________________________________________

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