The documentation for NSFileManager
seems to recommend not checking to see if files exist, and instead just trying to read the file and handle any errors gracefully (e.g. file not found error). What you are describing doesn't sound like a race condition—which is what the documentation's recommendation is trying to circumvent—but what happens if you just try to load the file rather than checking to see if it exists? You could, for example, try the following:
NSError *error;
NSStringEncoding encoding;
NSString *fileContents = [NSString stringWithContentsOfFile:fileName
usedEncoding:&encoding
error:&error];
if (fileContents == nil)
{
NSLog (@"%@", error);
}
else
{
NSLog (@"%@", fileContents);
}
If you get a string with all of the file's contents, then the file is obviously there. If you get an error then something is up with myManager
.