• 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: NSPasteboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPasteboard


  • Subject: Re: NSPasteboard
  • From: email@hidden
  • Date: Sun, 29 Feb 2004 13:37:54 -0800

Quoting email@hidden:

> Subject: NSPasteBoard
>
> I must be missing something obvious. I want to be able to copy text
> from an nstextview without tags. So I process the text and create a
> string called nText that has no tags and now want to export it to the
> clipboard.
>
> Here is how I send it to the pasteboard:
>
> a = [[NSPasteboard generalPasteboard] setString: nText forType:
> NSStringPboardType];
>
> Now I've done no setting of types, since I assumed that this would be
> preset. Am I missing something? It comes back with a == NO...

Matthew:

You're going to have to declare the types you're going to provide on that
pasteboard before actually providing the data.

Prior to your setString:forType:, you'll need to call:

[[NSPasteboard generalPasteboard]
declareTypes:[NSArray arrayWithObject:NSStringPboardType]
owner:self];

This allows the pasteboard system, in an orderly fashion, to mediate between
the different data providers using the system.

This mediation isn't a problem across applications, where the system should be
able to sense that one "owner" is implicitly different from another; but
within an application with potentially many data providers, it allows the
system to book-keep the handing off of pasteboard ownership between objects.

The pasteboard in your particular example is returning NO because it isn't
expecting a string to be provided to it yet. Conceivably there are cases where
your code wouldn't fail, because some other object inside your application had
previously promised, but not yet provided, a string representation of their
data. The return NO is flagging a potential error-condition in your code.

-Mark
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: What are argc and argv from Finder (was "Voodoo...")
  • Next by Date: Re: Databasing and Cocoa
  • Previous by thread: Re: NSPasteBoard
  • Next by thread: Locating application bundle from a nib file
  • Index(es):
    • Date
    • Thread