0

I have a struct here, which generates errors when Xcode tries to compile it

public struct GATToIPPermissions : OptionSet {

    public init(rawValue: UInt)


    public static var read: GATToIPPermissions { get {}}

    public static var write: GATToIPPermissions { get {}}

    public static var event: GATToIPPermissions { get {}}

    public static var all: GATToIPPermissions { get {}}
}

The error I get is Type GATToIPPermissions does not conform to protocol RawRepresentable. However, I dont get any indication as to why it doesn't conform.

Can any of you spot the problem?

Andriy
  • 2,767
  • 2
  • 21
  • 29
bingbomboom
  • 209
  • 1
  • 4

1 Answers1

0

That syntax you're written is what you would use within a protocol. If it were in a protocol, it would declare "Conforming types must implement an initializer called init(rawValue:), and have getters for the following properties of type GATToIPPermissions: read, write, event, and all"

But you're not aiming to write declarations in a protocol, you're looking to write implementations in a struct, and here is how that would look:

public struct GATToIPPermissions : OptionSet {

    public init(rawValue: UInt) {
        //initialize self with `rawValue`
    }


    public static let read = GATToIPPermissions() //set me to the right value
    public static let write = GATToIPPermissions() //set me to the right value
    public static let event = GATToIPPermissions() //set me to the right value
    public static let all = GATToIPPermissions() //set me to the right value
}
Mr. Xcoder
  • 4,719
  • 5
  • 26
  • 44
Alexander
  • 59,041
  • 12
  • 98
  • 151