<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FinderSync",
  "identifier" : "/documentation/FinderSync/FIFinderSyncController/setBadgeIdentifier(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Finder Sync"
    ],
    "preciseIdentifier" : "c:objc(cs)FIFinderSyncController(im)setBadgeIdentifier:forURL:"
  },
  "title" : "setBadgeIdentifier(_:for:)"
}
-->

# setBadgeIdentifier(_:for:)

Sets the badge for a file or directory.

```
func setBadgeIdentifier(_ badgeID: String, for url: URL)
```

## Parameters

`badgeID`

A unique ID, identifying the badge.

`url`

The URL of the file or directory.

## Discussion

Adds the specified badge to the given file or directory. Setting the
identifier to an empty string (`@""`) removes the badge.

Avoid adding badges to items that the Finder hasn’t displayed yet.
When setting the initial badge, call this method from your Finder Sync
extension’s [`requestBadgeIdentifier(for:)`](/documentation/FinderSync/FIFinderSyncProtocol/requestBadgeIdentifier(for:))
method. When updating badges, call this method only for items that have
already received a badge.

## See Also

[`-  requestBadgeIdentifierForURL:`](/documentation/FinderSync/FIFinderSyncProtocol/requestBadgeIdentifier(for:))

Requests a badge for the given file or directory.



---

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)