<!--
{
  "availability" : [
    "macOS: 10.9.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Progress/addSubscriber(forFileURL:withPublishingHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSProgress(cm)addSubscriberForFileURL:withPublishingHandler:"
  },
  "title" : "addSubscriber(forFileURL:withPublishingHandler:)"
}
-->

# addSubscriber(forFileURL:withPublishingHandler:)

Registers a file URL to hear about the progress of a file operation.

```
class func addSubscriber(forFileURL url: URL, withPublishingHandler publishingHandler: @escaping Progress.PublishingHandler) -> Any
```

## Parameters

`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()`](/documentation/Foundation/Progress/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()`](/documentation/Foundation/Progress/publish()) with a [`fileURLKey`](/documentation/Foundation/ProgressUserInfoKey/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()`](/documentation/Foundation/Progress/unpublish()), the publishing process terminates, or you invoke [`removeSubscriber(_:)`](/documentation/Foundation/Progress/removeSubscriber(_:)). The system invokes the blocks you provide on the main thread.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)