Apple suggests using an instance of NSFileManager
class and avoid the static class method defaultManager
because it will return a singleton instance: no thread-safe:
In Mac OS X v.10.5 and later you should consider using
[[NSFileManager alloc] init]
rather than the singleton method defaultManager. Using[[NSFileManager alloc] init]
instead, the resultingNSFileManager
instance is thread safe.
For example:
// bad
BOOL result = [[NSFileManager defaultManager] fileExistsAtPath:pathLocalRepository isDirectory:nil];
// good
NSFileManager *fm = [[NSFileManager alloc] init];
BOOL result = [fm fileExistsAtPath:pathLocalRepository isDirectory:nil];
[fm release];
fm = nil;