I have just been studying this code which checks if a file exists:
NSString *path;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"SomeDirectory"];
path = [path stringByAppendingPathComponent:@"SomeFileName"];
if ([[NSFileManager defaultManager] fileExistsAtPath:path])
{
but I'm a bit confused. by the following line:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
Ok I Understand that the Method NSSearchPathForDirectoriesInDomains returns a path depending on the arguments which you pass into this method. But this user (whoever wrote the code) is blindly passing in a whole class! (refering to NSDocumentDirectory, NSUserDOmainMask). The only thing he pass correctly is the BOOL YES. I check the apple docs and it says this:
NSSearchPathForDirectoriesInDomains Creates a list of directory search paths.
NSArray * NSSearchPathForDirectoriesInDomains (
NSSearchPathDirectory directory,
NSSearchPathDomainMask domainMask,
BOOL expandTilde
);
I have search for NSSearchPathDirectory and NSSearchPathDomainMask in apple docs and they suggest I have to pass a number
This would suggest a number needs to be passed into the method? Can somebody explain that line please? thanks