From the course: iOS Development: Security

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Prevent pasteboard leakage with coding

Prevent pasteboard leakage with coding - iOS Tutorial

From the course: iOS Development: Security

Start my 1-month free trial

Prevent pasteboard leakage with coding

- [Instructor] One way to avoid data leakage is to wipe out the contents of pasteboard when the app is about to move into the background. This transition occurs when we hit the home button while the app is running, or when we switch apps by double tapping the home button. But first, let me undo the secured text entry setting. This will re-enable the copying of text from the text field. Next, I switch to the AppDelegate. The AppDelegate application will resign active method is invoked before the app switches to the inactive state. So here's where we should clear the pasteboard. Let me scroll up a bit. We can erase our pasteboard data by setting its items property to an array that contains an empty dictionary. So UIpasteboard.general.items equals an array of empty dictionaries. The key should be a string, and the value can be any. I leave a breakpoint here to see when the execution gets here. Now let's begin the run. I'm going to type the password here. Select all. And copy is…

Contents