I have a piece of code which is said to return a bool value. I am a new programmer, so could someone give me code that will determine if the file at the path exists?
NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDirectory stringByAppendingPathComponent:@"fileName.txt"]; //returns a bool
Actualy the stringByAppendingPathComponent: method does not return (BOOL) it returns (NSString *).
You can tell by looking at its signature which is:
If it did return a bool (which it does not,) all you would have to do is:
if (path) {//...}What you actually want to do to test if a file exists is: