Search code examples
objective-cxcodecocoaappstore-sandbox

Get list of files in Library folder with sandbox in cocoa


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?


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];