Can I extend NSFileProviderItemCapabilities to create my own capability?

Viewed 13

I am using NSFileProviderItemCapabilities to manage functionality available to a user. One feature is whether the user can download a file or not. NSFileProviderItemCapabilities does not have this capability supported out-of-the-box.

I created the following

extension NSFileProviderItemCapabilities
{
    public static var allowsDownloading: NSFileProviderItemCapabilities {
        // All NSFileProviderItemCapabilities raw values go up in powers of 2 (expect allowsAll which is 63)
        return NSFileProviderItemCapabilities(rawValue: 62)
    }
}

var capabilities = Capabilities()
capabilities.insert(.allowsDownloading)

Using this custom capability results in the following being stored in the capabilities variable.

No allowsDownloading is present and other NSFileProviderItemCapabilities have been added.

enter image description here

Playing around, if I were to reduce the rawValue of allowsDownloading to 2, it adds the following capabilities.

enter image description here

Is extending NSFileProviderItemCapabilities not possible or am I doing something wrong?

0 Answers
Related