Question

I'm trying to get list of files in Library folder in cocoa, i use this code and NSHomeDrirectory() function without sandboxing and work well.

TempArray = [[NSFileManager defaultManager] directoryContentsAtPath:FolderURL]

but when I checked sandbox is code not work, Is it any entitlements should i add? or what code can replace?

Was it helpful?

Solution

I haven't tried if this will get all the files but it should since you can save and read files from the library.

NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSArray *libraryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:libraryPath error:nil];

OTHER TIPS

If you add below entitlement you can access ~/Library or /Library folders

  com.apple.security.temporary-exception.files.home-relative-path.read-write: /Library/

But after this you will get reply from apple is

2.31:Apps that are not sandboxed appropriately may be rejected I didn't get answer of this. If anyone knows please post here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top