I need to access a shared file hosted on a mac shared folder, However when I directly pass the path to the NSFileManager it reports as file does not exist.
NSURL *fileURLPath = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@,%@",IP,PATH ]];
if ([[NSFileManager defaultManager] fileExistsAtPath:[fileURLPath path]])
{
}
I believe it’s due to the authentication . How should handle or pass the credentials using the NSFileManager ?
It would be useful to see what your resulting URL looks like. If I understand your variable naming correctly, you’re creating an invalid URL. If IP is
@"127.0.0.1"and path is@"foo", the resulting URL will befile://127.0.0.1,foo, which isn’t a valid URL.NSFileManagerexpects a file URL pointing to a descendant directory of the mount point. This implies that the share has to be mounted. Authentication is not required.