removeFileAtPath:handler:
Deletes the file, link, or directory (including, recursively, all subdirectories, files, and links in the directory) identified by a given path.
Declaration
- (BOOL) removeFileAtPath:(NSString *) path handler:(id) handler;Parameters
- path:
The path of a file, link, or directory to delete. The value must not be “
.” or “..”. - handler:
An object that responds to the callback messages Filemanager(_:willprocesspath:) and Filemanager(_:shouldproceedaftererror:). You can specify
nilforhandler; if you do so and an error occurs, the deletion stops and the method automatically returns False.
Return Value
true if the removal operation is successful. If the operation is not successful, but the handler method fileManager(_:shouldProceedAfterError:) returns true, also returns true; otherwise returns false.
Discussion
This callback mechanism provided by handler is similar to delegation. NSFileManager sends fileManager(_:willProcessPath:) when it begins a copy, move, remove, or link operation. It sends fileManager(_:shouldProceedAfterError:) when it encounters any error in processing.
Since the removal of directory contents is so thorough and final, be careful when using this method. If you specify “.” or “..” for path an NSInvalidArgumentException exception is raised. This method does not traverse symbolic links.
Special Considerations
Because this method does not return error information, it has been deprecated as of OS X v10.5. Use removeItem(at:) instead.
See Also
Related Documentation
Deprecated Methods
copyPath:toPath:handler:movePath:toPath:handler:changeFileAttributes(_:atPath:)fileAttributes(atPath:traverseLink:)fileSystemAttributes(atPath:)directoryContents(atPath:)createDirectory(atPath:attributes:)createSymbolicLink(atPath:pathContent:)pathContentOfSymbolicLink(atPath:)linkPath:toPath:handler:fileManager(_:shouldProceedAfterError:)fileManager(_:willProcessPath:)