Reputation: 2099
I used the codes below to check if a file exists
bool b=[[NSFileManager defaultManager] fileExistsAtPath:filePath];
The codes worked on IOS.
But When I migrate it to mac os x,
But I found whether the file exists on disk with filePath, b always returns 0, which means the file does not exists.
I wonder if there is difference between ios and macosx
Welcome any comment
Upvotes: 11
Views: 14772
Reputation: 40621
From docs, I think you're using path with tilde
path
The path of a file or directory. If path begins with a tilde (~), it must first be expanded with stringByExpandingTildeInPath, or this method will return NO.
tilde
makes path relative to your home directory (such as /Users/username/
)
you can find out by calling NSLog(@"%@",filePath);
if filePath is of type NSString
Upvotes: 5