• 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: [Q] availableTypeFromArray returns NXFileContentsPboardType instead of NSFileContentsPboardType
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] availableTypeFromArray returns NXFileContentsPboardType instead of NSFileContentsPboardType


  • Subject: Re: [Q] availableTypeFromArray returns NXFileContentsPboardType instead of NSFileContentsPboardType
  • From: "Michael Ash" <email@hidden>
  • Date: Thu, 18 Dec 2008 16:55:34 -0500

On Thu, Dec 18, 2008 at 2:09 PM, JongAm Park
<email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >[Q] availableTypeFromArray returns NXFileContentsPboardType instead of NSFileContentsPboardType (From: JongAm Park <email@hidden>)

  • Prev by Date: Re: NSToolbar Error
  • Next by Date: Re: Question Regarding the Memory Address of Objects
  • Previous by thread: [Q] availableTypeFromArray returns NXFileContentsPboardType instead of NSFileContentsPboardType
  • Next by thread: Preventing Automatic Gzip Decompression with NSURLConnection?
  • Index(es):
    • Date
    • Thread