Today we will learn How to use UIPasteBoard for giving copy paste option within our app or  from one app to other. More Details

Steps:

  1. Create a new Xcode Project and Lets say (PasteBoardDemo).
  2.  Now go to StoryBoard and take one textView, TextField and a button. Make Proper connection.

Screen Shot 2016-09-11 at 1.17.52 AM.png

  1. Now go to Your ViewController.m and write this code in Your Button Action.

– (IBAction)buttonAction:(id)sender {

    

    NSString *copyiedString = self.textView.text;

    UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];

    pasteBoard.string = copyiedString;

}

Now run the code and see the desired output. You can download the whole source code from   here.

Do like and share Your feedback.

Enjoy Coding 🙂

Advertisements