From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Copy and paste with the pasteboard

Copy and paste with the pasteboard

From the course: iOS Development Tips

Copy and paste with the pasteboard

- All day long, you use Command X, Command C, and Command V to cut, copy and paste from the pasteboard. You see that functionality in other applications. How do you get that functionality? In this video, I'll show you the basics of using the pasteboard to copy and paste data, not only in your app, but over the sandbox wall and into other applications. If you run the starter file, I've set up a small application to type into the text view. Go ahead and run it. And you'll see that there are two buttons at the top for copying and pasting the text. Stop the app and we'll make the code for these buttons. Head into View Controller and before we do anything else, I'm going to add a constant. Let pasteboard equal UIPasteboard dot general. This is the general pasteboard. It's the only persistent pasteboard, and the only pasteboard which can copy and paste outside your app. Move down the code a bit to the copy text action. Many of the simple types, like strings and numbers, have special methods…

Contents