Can you find a bug in this line of code? It returns nil!! The app is completely sandboxed but Downloads folder access is enabled.
NSArray*array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"/Downloads/"] error:NULL];
//array==nil: Why?
[EDIT] Problem: I cannot test it. It is happening on a Guest account of the review machines. Could there be something wrong with the complied binary or have you got any tips how to solve this issue?
Try to read the directory with an error handle to examine what happens:
NSError *error = nil;
NSArray*array = [[NSFileManager defaultManager]
contentsOfDirectoryAtPath:
[NSHomeDirectory() stringByAppendingPathComponent:@"/Downloads/"]
error:&error];
if ( !array )
NSLog(@"ERROR: %@", [error description]);
That will give you a more detailed description what went wrong.
To log this error to a file quick'n'dirty use the following message:
[[error description] writeToFile:@"strangeerrors.log"
atomically:NO encoding:NSUTF8StringEncoding error:nil];