Why Library directory doesn't appear (exist) when I use playground in xcode?

96 Views Asked by At

I'm practicing data persistence in xcode using property lists. I read that every application has a sandbox with the directories: Documents, Library and temp. So I tried to write some data into the Library directory. For that, I use a playground with the next code (xcode 9.2, swift 4)

import UIKit

var puntNUM = [1]
let fm = FileManager.default
let url = fm.urls(for: .libraryDirectory, in: .userDomainMask)
let f = url[0].appendingPathComponent("borrable.plist")
let penc = PropertyListEncoder()
let d = try! penc.encode(puntNUM)
try! d.write(to: f)

However, it doesn't work. I search in the direction that Library is supposed to be (using url from code), but it doesn't exist. Why is there no Library directory? The Documents directory does exist.

Thanks in advance

0

There are 0 best solutions below