Re: Copying contents of an NSString to the Clipboard
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