Verifique se o caminho no marcador no escopo do aplicativo é gravável dentro do aplicativo em área restrita

Eu tenho um aplicativo OS X, que armazena um marcador no escopo do aplicativo para manter o acesso a determinados diretórios. Consigo gravar nesses diretórios sem problemas, mas há uma parte no meu código em que desejo fazer uma verificação extra para confirmar se o caminho é gravável e falha.

var fileManager: NSFileManager = NSFileManager.defaultManager()
var baseUrl: NSURL = try! NSURL(byResolvingBookmarkData: data, …)
var fileUrl: NSURL = url.URLByAppendingPathComponent("foo.txt")

// Changing this order has no effect, I make only the first start access call,
// the second one is to demonstrate that it's not working.

baseUrl.startAccessingSecurityScopedResource() // true
fileUrl.startAccessingSecurityScopedResource() // false

// File manager confirms that base path is writable, but anything inside
// it – not. This worked perfectly fine before sandboxing the app.

fileManager.isWritableFileAtPath(baseUrl.path!) // true
fileManager.isWritableFileAtPath(fileUrl.path!) // false

// Writing file to the `fileUrl` works anyway, even though
// file manager thinks it's not writable.

writeMyFile(toUrl: fileUrl)

// Here's another interesting observation, is writable starts working
// once the files get created.

fileManager.isWritableFileAtPath(fileUrl.path!) // false
fileManager.createFileAtPath(fileUrl.path!, contents: nil, attributes: nil)
fileManager.isWritableFileAtPath(fileUrl.path!) // true

Estou fazendo algo errado ou há algum problema com o gerenciador de arquivos dentro de uma caixa de areia? Existe uma maneira decente de verificar se o subcaminho é gravável, ou seja, sem criar arquivos?

questionAnswers(0)

yourAnswerToTheQuestion