UIPasteboard Item on MacOS is Not Expiring

Hello,

When running an iPad app on Apple Silicon (M1) the expirationDate OptionKey of the UIPasteboard has no impact, i.e. the copied value is never removed from the clipboard.

The following code works perfectly on iOS, however, behaves how I described above on macOS.

let currentDate = Date()
let expireDate = currentDate.addingTimeInterval(TimeInterval(90))

UIPasteboard.general.setItems([[UIPasteboard.typeAutomatic: myString]], options: [UIPasteboard.OptionsKey.expirationDate: expireDate])

Is this a bug? I am on Swift 5.10.

Thank you!

Replies

Is this a bug?

I think this is one of those “It depends on your point of view.” things. macOS traditionally has not supported expiring pasteboard items, so it’s not clear what the correct user-level behaviour is here. If you have thoughts on this, I recommend that you file a bug that describes your use case.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"