i have 3 classes
class A {
var uid: Int64!
var countryCode: String? // <-- Attention
}
class B {
var uid: Int64!
var countryCode: String! // <-- Attention
}
class C {
var uid: Int64!
var countryCode: String = "AA" // <-- Attention
}
witch var for example countryCode
as String?
, String!
, String
and i create protocol, witch var as String?
(As the weakest type to which you can bring all the others)
protocol FullCode {
var uid: Int64! { get }
var countryCode: String? { get } // <-- How to describe a variable for all (`T`, `T!`, `T?`) types?
}
extension FullCode {
var fullCode: String? { return "specificCode"}
}
bat if i added it to my classes
extension A : FullCode {}
extension B : FullCode {}
extension C : FullCode {}
i get error for classes B & C.
How can use one protocol for these types?