I use UIPasteboard
to copy/paste text between two UITextView
.
Code looks like this:
- (void)viewDidLoad {
[super viewDidLoad];
pasteBoard = [UIPasteboard generalPasteboard]; //it is declared in .h as UIPasteboard *pasteBoard;
}
-(IBAction)doCopyBtn {
if (![toCopyTextView.text isEqualToString:@""]){
pasteBoard.string = toCopyTextView.text;
NSLog(@"pasteb1 %@", pasteBoard.string);
} else {
NSLog (@"error! enter smth");
}
}
-(IBAction)doPasteBtn {
if (![pasteBoard.string isEqualToString:@""]){
toPasteTextView.text = pasteBoard.string;
NSLog(@"pasteb2 %@", pasteBoard.string);
} else {
NSLog (@"error! enter smth");
}
}
And even this cant help (NSLog returns: pasteb2 (null)
)
-(void) viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[pasteBoard setString:@""];
}
Here’s how to empty the clipboard. To delete all clips or an individual clip, first open the Clipboard task pane. On the Home tab, in the Clipboard group, click the Clipboard dialog box launcher.
Subclasses can override this method and use it to commit editing changes, resign the first responder status of the view, or perform other relevant tasks. For example, you might use this method to revert changes to the orientation or style of the status bar that were made in the viewDidAppear (_:) method when the view was first presented.
or view the history of the contents of the clipboard. 1. Go to start and type in the search box “RUN” and hit enter. 2. In the command window type in cmd /c “echo off | clip” in the text box and press enter. 3. Instantly a window will come and disappear in front of you.
Clear the clipboard 1 On the Home tab, in the Clipboard group, click the Clipboard dialog box launcher. 2 The Clipboard task pane appears on the left side of your spreadsheet and shows all clips in the clipboard. 3 To clear the entire clipboard, click the Clear All button. More items...
UIPasteboard
Try the following:
UIPasteboard *pb = [UIPasteboard generalPasteboard];
[pb setValue:@"" forPasteboardType:UIPasteboardNameGeneral];
Arab_Geek's response is correct but available for Cocoa (and I suspect you are looking for an iOS solution)
NSPasteboard
Here you go ..
NSPasteboard *pb = [NSPasteboard generalPasteboard];
[pb declareTypes: [NSArray arrayWithObject:NSStringPboardType] owner: self];
[pb setString: @"" 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