Got 1 UITextField and 1 button. There is text in my textfield, and when we click on the button, the text is copied to the OSX clipboard.
How can I do that? I've readed the NSPastboard Class Reference but didn't understand how to do that -simply-
Got my button defined in my AppControler.h like this:
- (IBAction)copyButton:(id)sender;
What am I supposed to write in my AppControler.m? My textfield is called "descTextField"
- (IBAction)copyButton:(id)sender {
NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
[pasteBoard declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:nil];
[pasteBoard setString: [textField stringValue] forType:NSStringPboardType];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With