Hi,
I'm using Apples API (Connect), which makes use of 'self'. I've created the below class, however i get a couple of errors:
'Cannot assign to value: 'self' is immutable'
and
Cannot assign value of type 'URL' to type 'AppleConnectModel.Links'
code:
class Links: ObservableObject, Codable {
@Published var `self`: URL
required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
`self` = try container.decode(URL.self, forKey: .`self`)
}
private enum CodingKeys: String, CodingKey {
case `self`
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(`self`, forKey: .`self`)
}
}
I'm not sure what i'm going wrong. To make use of a keyword i use backticks `` i.e. self.
Any pointers/help would be appreciated.
Selecting any option will automatically load the page