20200713--iOS之FileManagerDelegate协议,文件管理协议

本文深入探讨了文件管理器委托(FileManagerDelegate)的作用与用法,详细解释了如何通过实现可选方法来干预文件和目录的复制、移动、链接及删除操作。了解如何在操作开始前或遇到错误时,通过委托决定操作的执行流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

func fileManager(FileManager, shouldProceedAfterError: Error, movingItemAtPath: String, toPath: String) -> Bool

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.

func fileManager(FileManager, shouldProceedAfterError: Error, copyingItemAtPath: String, toPath: String) -> Bool

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.

func fileManager(FileManager, shouldProceedAfterError: Error, linkingItemAtPath: String, toPath: String) -> Bool

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

 

About Apple File System

Use high-level APIs to get the most out of Apple File System.

class FileManager

A convenient interface to the contents of the file system, and the primary means of interacting with it.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值