1

I am trying to write a code with objective-C in Xcode to read a text from clipboard and print it to console I have some trouble. with that. I would appreciate if you can help me to write this code.

Thank you

danywarner
  • 928
  • 2
  • 15
  • 28
user3795105
  • 69
  • 1
  • 3
  • 7
  • Possible duplicate of [XCode 4.3 Text from clipboard automatically in TextView by entering](http://stackoverflow.com/questions/10364142/xcode-4-3-text-from-clipboard-automatically-in-textview-by-entering) – Manuel Spigolon Jul 05 '16 at 13:29
  • Stackoverflow is not a code writing service, and not a programming school either. – Eiko Jul 05 '16 at 14:50

1 Answers1

0

You should use UIPasteboard class from UIKit framework.

Apple doc says

The UIPasteboard class provides pasteboards: protected areas for sharing data within an app or between apps. The class offers methods for writing and reading items of data to and from a pasteboard.

for further reference apple doc link 1, link 2

add this method in your viewcontroller and call it.

-(void)printClipboardContent{

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    NSString *string = pasteboard.string;
    Nslog (@"clipboard text :%@",string);


}
Anshad Rasheed
  • 2,526
  • 1
  • 14
  • 32