I had this variable in a my viewController var category : QCategoryy?
and I decided to turn it into an array so I created this: var categories: [QCategoryy?]? = []
but after that i get all errors like this
"Value of type '[QCategoryy?]' has no member 'name'"
in this line self.title = categories?.nameand other lines like that.
Why i get these errors and how can i solve it?
First to turn the var into an array all worked well. This is the class of QCategoryy
struct QCategoryy {
var name:String
var isSelected = false
init(name:String) {
self.name = name
}
}
extension QCategoryy: ExpressibleByStringLiteral {
init(stringLiteral value: String) {
self.name = value
}
init(unicodeScalarLiteral value: String) {
self.init(name: value)
}
init(extendedGraphemeClusterLiteral value: String) {
self.init(name: value)
}
}
self.title = categories?.first??.name, for instance.