Protocol
FileManagerDelegate
The interface a file manager's delegate uses to intervene during operations or if an error occurs.
--文件管理器的委托,用于在操作期间或发生错误时进行干预的接口。(与文件管理器结合使用)
Declaration --声明
protocol FileManagerDelegate
Overview --概览
The FileManagerDelegate
protocol defines optional methods for managing operations involving the copying, moving, linking, or removal of files and directories. When you use an FileManager
object to initiate a copy, move, link, or remove operation, the file manager asks its delegate whether the operation should begin at all and whether it should proceed when an error occurs.
--FileManagerDelegate协议定义了可选的方法,用于管理涉及复制、移动、链接或删除文件和目录的操作。当使用FileManager
对象初始化复制、移动、链接或删除操作时,文件管理器会询问其委托是否应该开始操作,以及在出现错误时是否应该继续操作。
The methods of this protocol accept either NSURL
or NSString
objects. The file manager always prefers methods that take an NSURL
object over those that take an NSString
object.
--该协议的方法可以接受NSURL或NSString对象。但文件管理器总是更喜欢使用NSURL对象的方法,而不是使用NSString对象的方法。
You should associate your delegate with a unique instance of the FileManager
class, as opposed to the shared instance.
--您应该将委托与FileManager类的唯一实例相关联,而不是与共享实例相关联。
Topics --专题
Moving an Item --移动项
func fileManager(FileManager, shouldMoveItemAt: URL, to: URL) -> Bool
Asks the delegate if the file manager should move the specified item to the new URL.
func fileManager(FileManager, shouldMoveItemAtPath: String, toPath: String) -> Bool
Asks the delegate if the file manager should move the specified item to the new path.
func fileManager(FileManager, shouldProceedAfterError: Error, movingItemAt: URL, to: URL) -> Bool
Asks the delegate if the move operation should continue after an error occurs while moving the item at the specified URL.
Asks the delegate if the move operation should continue after an error occurs while moving the item at the specified path.
Copying an Item --复制项
func fileManager(FileManager, shouldCopyItemAt: URL, to: URL) -> Bool
Asks the delegate if the file manager should copy the specified item to the new URL.
func fileManager(FileManager, shouldCopyItemAtPath: String, toPath: String) -> Bool
Asks the delegate if the file manager should copy the specified item to the new path.
func fileManager(FileManager, shouldProceedAfterError: Error, copyingItemAt: URL, to: URL) -> Bool
Asks the delegate if the move operation should continue after an error occurs while copying the item at the specified URL.
Asks the delegate if the move operation should continue after an error occurs while copying the item at the specified path.
Removing an Item --移除项
func fileManager(FileManager, shouldRemoveItemAt: URL) -> Bool
Asks the delegate whether the item at the specified URL should be deleted.
func fileManager(FileManager, shouldRemoveItemAtPath: String) -> Bool
Asks the delegate whether the item at the specified path should be deleted.
func fileManager(FileManager, shouldProceedAfterError: Error, removingItemAt: URL) -> Bool
Asks the delegate if the operation should continue after an error occurs while removing the item at the specified URL.
func fileManager(FileManager, shouldProceedAfterError: Error, removingItemAtPath: String) -> Bool
Asks the delegate if the operation should continue after an error occurs while removing the item at the specified path.
Linking an Item --链接项
func fileManager(FileManager, shouldLinkItemAt: URL, to: URL) -> Bool
Asks the delegate if a hard link should be created between the items at the two URLs.
func fileManager(FileManager, shouldLinkItemAtPath: String, toPath: String) -> Bool
Asks the delegate if a hard link should be created between the items at the two paths.
func fileManager(FileManager, shouldProceedAfterError: Error, linkingItemAt: URL, to: URL) -> Bool
Asks the delegate if the operation should continue after an error occurs while linking to the item at the specified URL.
Asks the delegate if the operation should continue after an error occurs while linking to the item at the specified path.
Relationships
Inherits From
See Also
File System Operations
Use high-level APIs to get the most out of Apple File System.
A convenient interface to the contents of the file system, and the primary means of interacting with it.