Why don't you just use a local variable?
NSFileManager *fm = [NSFileManager defaultManager];
or better yet, enter the file manager as an argument to the method:
- (void)myMethod {
becomes
- (void)myMethodWithFileManager:(NSFileManager*)fm {
Since defaultManager is singleton (virtually global), it makes testing very difficult. Dependency injection saves you typing (as needed) in the method and makes it much easier to unit test - you can enter a test double instead of the standard Manager.
Finally, Cocoa and Objective-C tend to decline in favor of explicit short code. The philosophy is basically that using more detailed names makes the code easier to read (and therefore maintain). This philosophy is fully consistent with the Objective-C style, with alternating named arguments. If you really can't handle the extra text input (and the completion of the Xcode code will not work for you), stick with the existing names. When in Rome and all this ...
source share