Copy NSString to Clipboard

Filed under Cocoa + Objective-C on Sunday, 20 September, 2009 12:09 pm

Coming back to the ultimate purpose of this blog... helping my memory! :D
Here we are: a code snippet to copy a NSString to the clipboard...

-(void)copyToClipboard:(NSString*)str
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [NSArray     arrayWithObjects:NSStringPboardType, nil];
[pb declareTypes:types owner:self];
[pb setString: str forType:NSStringPboardType];
}

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

8) :wink: :P :D :) :o :? :( :x