---
title: "setBadgeIdentifier(_:for:)"
framework: Finder Sync
role: symbol
role_heading: Instance Method
platforms: [macOS 10.10+]
path: "findersync/fifindersynccontroller/setbadgeidentifier(_:for:)"
---

# setBadgeIdentifier(_:for:)

Sets the badge for a file or directory.

## Declaration

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

## Parameters

- `badgeID`: A unique ID, identifying the badge.
- `url`: The URL of the file or directory.

## Discussion

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:) method. When updating badges, call this method only for items that have already received a badge.

## See Also

### Related Documentation

- [requestBadgeIdentifier(for:)](findersync/fifindersyncprotocol/requestbadgeidentifier(for:).md)

### Managing the Finder Sync Controller

- [default()](findersync/fifindersynccontroller/default().md)
- [directoryURLs](findersync/fifindersynccontroller/directoryurls.md)
- [selectedItemURLs()](findersync/fifindersynccontroller/selecteditemurls().md)
- [setBadgeImage(_:label:forBadgeIdentifier:)](findersync/fifindersynccontroller/setbadgeimage(_:label:forbadgeidentifier:).md)
- [targetedURL()](findersync/fifindersynccontroller/targetedurl().md)
