addSubscriber(forFileURL:withPublishingHandler:)
Registers a file URL to hear about the progress of a file operation.
Declaration
class func addSubscriber(forFileURL url: URL, withPublishingHandler publishingHandler: @escaping Progress.PublishingHandler) -> AnyParameters
- url:
The URL of the file to observe.
- publishingHandler:
A closure that the system invokes when a progress object that represents a file operation matching the specified URL calls Publish().
Return Value
A proxy of the progress object to observe.
Discussion
The system invokes the passed-in block when a progress object calls publish() with a fileURLKey user info dictionary entry that’s a URL that is the same as this method’s URL, or that is an item that the URL directly contains. The progress object that passes to your block is a proxy of the published progress object. The passed-in block may return another block. If it does, the system invokes the returned block when the observed progress object invokes unpublish(), the publishing process terminates, or you invoke removeSubscriber(_:). The system invokes the blocks you provide on the main thread.