FileManager Expert? Apps sandboxing? "NavigatingHierarchicalDataUsingOutlineAndSplitViews"?

(1) Hi All, I'm a bit of a newbie to Apple, but have used FreeBSD/Linux so I'm somewhat familiar with it's file systems and access with C, C++, and TclTk. I'm really trying to wrap my head around the "Apple FileManager" but find their documentation difficult without the best of examples. Are there any good books out on Xcode, Apple Foundation usage (FileManager) and the NSFileSystem?, etc? Or how to even read and understand Apple's Developer Documents?

(2) Does anyone out there have experience with "NavigatingHierarchicalDataUsingOutlineAndSplitViews" in the Apple docs. If so please read the following.

I've been playing with it to try and help understand the Apple File System and usage. I've put in a print("debug", url) in the function func addFileSystemObject(_ url: URL, indexPath: IndexPath) {

In the code, I've located where they load a default example directory for viewing in their app in their file "OutlineViewController.swift". The code is
let appsURLs = FileManager.default.urls(for: .applicationDirectory, in: .localDomainMask) addFileSystemObject(appsURLs[0], indexPath: IndexPath(indexes: [0, 0]))
It does as expected. The file URL is " debug file:///Applications/".

However when I change the directory such as
let docsURLs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) addFileSystemObject(docsURLs[0], indexPath: IndexPath(indexes: [0, 0]))

I would of expected it locating my Documents Directory (which is iClouded) under my user directory.
Instead it creates a directory... "debug print file:///Users/me/Library/Containers/com.example.apple-samplecode.SourceViewMD7FZBNW84/Data/Documents/"

I believe the demo app is sandboxing me correct?

But when I drag and drop a folder from my user documents directory into the app from finder it's "debug result is...
" debug file:///Users/me/Documents/MyFolder/ "

Thanks, I know this is long winded. Thanks - Jim

Or how to even read and understand Apple's Developer Documents?

Sadly, all the good documentation on the file system is in the Documentation Archive )-: The two I’d recommend for your situation are:

Beyond that, this is somewhat off-topic for Swift Forums so if you have follow-up questions I recommend that you post them to Apple Developer Forums. Use some combination of the Files and Storage, Foundation, and App Sandbox tags, depending on the specific question, and I’ll respond there.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like