• 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: Copying contents of an NSString to the Clipboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying contents of an NSString to the Clipboard


  • Subject: Re: Copying contents of an NSString to the Clipboard
  • From: "I. Savant" <email@hidden>
  • Date: Mon, 21 Apr 2008 13:13:16 -0400

>  I've studied the pasteboard docs, and wonder if there is a simple way to
> copy the contents of an NSString to the general clipboard. In AS or AS
> Studio it's just "set the clipboard to <variable>." Is there such a
> convenience method in Cocoa?

  Study the docs again, the answers are there if you've carefully read
the entire document:

http://developer.apple.com/documentation/Cocoa/Conceptual/CopyandPaste/Articles/pbImplementing.html

  Cobbled-together example from example code found in the "Lazy
Writing" section, only slightly modified:

NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [NSArray arrayWithObjects:NSStringPboardType, nil];
[pb declareTypes:types owner:self];
[pb setString:@"Read the docs carefully!" forType:NSStringPboardType];

--
I.S.
_______________________________________________

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: 
 >Copying contents of an NSString to the Clipboard (From: Johnny Lundy <email@hidden>)

  • Prev by Date: Re: Conflicting encodings issue in a Cocoa app
  • Next by Date: Re: NSTableView -editColumn:row:withEvent:select: question
  • Previous by thread: Copying contents of an NSString to the Clipboard
  • Next by thread: Consistent Contextual Menu in NSTableview
  • Index(es):
    • Date
    • Thread