I have an NSString containing a path, but it could be either a file, or a directory.
Is there an equivalent to the Python os.path.isdir() and os.path.isfile() methods in Cocoa?
From stackoverflow
-
See the NSFileManager Class Reference
[[NSFileManager defaultManager] fileExistsAtPath:pathname isDirectory:&directoryFlag];For example:
NSString *file = @"/tmp/"; BOOL isDir; if([[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDir] && isDir){ NSLog(@"Is directory"); }
0 comments:
Post a Comment