Yep, should be easy. Get the text from the view. Then use the methods in UIPasteboard. In particular the generalPasteboard class method and setValue:forPasteboardType: methods. Did you even open the documentation before asking this?
- (IBAction)btnCopyClicked:(id)sender {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setValue: @"Test" forPasteboardType: @"public.utf8-plain-text"];
NSLog(@"Pasteboard: %@", pasteboard.string);
}
In neither method are you setting pasteboard to anything. Where do you set it to a valid instance of UIPasteboard? Are you sure it's set?
Have you tried:
Code:- (IBAction)btnCopyClicked:(id)sender { UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; [pasteboard setValue: @"Test" forPasteboardType: @"public.utf8-plain-text"]; NSLog(@"Pasteboard: %@", pasteboard.string); }