From the course: iOS Development: Security

Unlock the full course today

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

Using the new file protection level

Using the new file protection level - iOS Tutorial

From the course: iOS Development: Security

Start my 1-month free trial

Using the new file protection level

- [Instructor] Now let's use the new method. To keep it simple, I'm going to call it from the viewDidLoad method. Let's scroll down to the viewDidLoad method. At first, I define the text constant with one persist. Let text equals and our super secret text. Next, we'll create the URL of the file to write the data into. I use the default file manager and cause the URL instance method to initialize the file URL. This method might throw, therefore I use conditional binding and try question mark to call it. If let my URL, the name of the constant, and I use conditional try, file manager default, URL, and we need this version. Let's create our file within the documents directory. For the first parameter, I'm going to provide the document directory as input. For the file system domain, I specify user domain mask, which gives the user's home directory, dot user domain mask, appropriate for can be ignored in this case, so I press in nil, and finally, the create argument should be false. That…

Contents