NSFileManager Lists all Files - Sandbox

When we execute the below code with developer profile

[[NSFileManager defaultManager] directoryContentsAtPath:@"/"]

, why would we see all folders and files. Does it mean we can access view all the folders, even though iOS apps. work in Sandbox.?


<__NSArrayM>(

.Trashes,

.ba,

.file,

.mb,

Applications,

Developer,

Library,

System,

bin,

cores,

dev,

etc,

private,

sbin,

tmp,

usr,

var

)

Replies

Does it mean we can access view all the folders, even though iOS apps.

No. iOS only guarantees that you’ll be able to access files within your app’s container (and any shared containers you support via the shared app groups feature). The sandbox could potentially block any access outside of those locations.

Right now the sandbox does not actually block all such accesses — which is why you’re able to iterate the contents of the root directory — but that’s just an implementation detail.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"