Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying contents of an NSString to the Clipboard



>  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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Copying contents of an NSString to the Clipboard (From: Johnny Lundy <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.