Type Method
removeDirectory(_:)removeDirectory:error: removeDirectory_error_
Removes the specified directory and its contents asynchronously using Grand Central Dispatch (GCD).
Declaration
class func removeDirectory(_ directoryPath: String) throwsDeclaration
+ (BOOL) removeDirectory:(NSString *) directoryPath error:(NSError **) error;Declaration
removeDirectory_error_(directoryPath: str) -> tuple[bool, NSError]Parameters
directoryPathThe path of the directory to be removed. This path must not be
nil.
Parameters
directoryPathThe path of the directory to be removed. This path must not be
nil.errorA pointer to an
NSErrorobject. This parameter is optional and can benil. If an error occurs during the removal process, this pointer will contain an error object describing the problem.
Discussion
This method removes all files and subdirectories within the specified directory. It performs the removal operations asynchronously on a background queue to avoid blocking the main thread. The method waits for all removal tasks to complete before returning, ensuring that the directory and its contents are fully deleted.
This method uses dispatch_group_t to manage and synchronize concurrent removal tasks. Each subdirectory removal is dispatched to a global concurrent queue, and the method waits for all dispatched tasks to complete before returning. This ensures that the method does not return until the entire directory and its contents have been successfully removed. If any error occurs, the method returns NO and populates the error parameter with the relevant error information.
Return Value
YES if the method succeeded, otherwise NO.
Discussion
This method removes all files and subdirectories within the specified directory. It performs the removal operations asynchronously on a background queue to avoid blocking the main thread. The method waits for all removal tasks to complete before returning, ensuring that the directory and its contents are fully deleted.
This method uses dispatch_group_t to manage and synchronize concurrent removal tasks. Each subdirectory removal is dispatched to a global concurrent queue, and the method waits for all dispatched tasks to complete before returning. This ensures that the method does not return until the entire directory and its contents have been successfully removed. If any error occurs, the method returns NO and populates the error parameter with the relevant error information.