Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4597302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:14:16+00:00 2026-05-21T23:14:16+00:00

I’ve got an NSPasteboard: NSPasteboard *pasteboard; and get it with: pasteboard = [[NSPasteboard generalPasteboard]

  • 0

I’ve got an NSPasteboard:

NSPasteboard *pasteboard;

and get it with:

pasteboard = [[NSPasteboard generalPasteboard] retain];

Now I want to determine of what type the last entry is, like formatted text or image etc. and if text, get the contents of it etc.

How do I find out the type of data hold in the pastboard?

I logged the output from [pasteboard types]:

2011-05-07 20:13:30.491 YourApp[15335:903] Pasteboard changed: (
    "public.utf8-plain-text",
    NSStringPboardType,
    "dyn.ah62d4rv4gu8y63n2nuuhg5pbsm4ca6dbsr4gnkduqf31k3pcr7u1e3basv61a3k",
    "NeXT smart paste pasteboard type"
)

but I’m not sure how to check if it’s text or anything else…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:14:17+00:00Added an answer on May 21, 2026 at 11:14 pm

    This is covered fully in the Pasteboard Programming Guide. The standard way to do this is to make a list of the types you are interested in and then just ask the pasteboard to give you those types. If it has objects of those types, you get them. Otherwise, you get nothing.

    NSPasteboard * pboard = [NSPasteboard generalPasteboard]; 
    NSArray * interestingTypes;
    interestingTypes = [NSArray arrayWithObjects:[NSAttributedString class], 
                                                 [NSString class], nil];
    NSArray * pboardContents = [pboard readObjectsForClasses:interestingTypes
                                                     options:nil];
    if( pboardContents ) {
        // Use the contents
    }
    

    You can also make multiple inquiries with different lists of types:

    NSArray * imgType = [NSArray arrayWithObject:[NSImage class]];
    NSArray * strType = [NSArray arrayWithObject:[NSString class]];
    
    NSArray * pboardImg = [pboard readObjectsForClasses:imgType
                                                 options:nil];
    NSArray * pboardStr = [pboard readObjectsForClasses:strType
                                                 options:nil];
    
    if( pboardImg ){
        // Got an image!
    }
    
    if( pboardStr ){
       // Got a string!
    }
    

    You can also simply ask the pasteboard if it has one of the types you’re interested in, without actually getting the objects. This will give you a simple YES or NO:

    [pboard canReadObjectForClasses:interestingTypes
                            options:nil];
    

    Note that pasteboard handling changed in Snow Leopard, so this is, unfortunately, all different in Leopard.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.