0

I have a situation like this:

@AppStorage("test") var obj = Set<String>()

However, Set does not conform to RawRepresentable which @AppStorage requires.

So, I did this:

extension Sequence: RawRepresentable where Element: Codable {
    
}

I'm trying to make Sequence conform to RawRepresentable, so I can use any type of collection for @AppStorage, however I get the error message

Extension of protocol 'Sequence' cannot have an inheritance clause

Is there any way to make it possible for Sequence to conform to RawRepresentable when its elements are Codable?

newswiftuser
  • 218
  • 8
  • No, this is not possible. In Swift you can extend a specific type to conform to a protocol, but you cannot extend all types that conform to one protocol to conform to another protocol. – Rob Napier Jul 03 '21 at 19:06

0 Answers0