I have this mapper:
import Foundation
import ObjectMapper
class Article: Mappable {
var id: Int!
var name: String!
var image: String!
var children: Article!
required init?(_ map: Map) {
mapping(map)
}
func mapping(map: Map) {
id <- map["id"]
name <- map["name"]
image <- map["image"]
children <- map["children"]
}
}
and then i need to loop and find article by id:
func getArticleName(aid) {
for article in articleList {
if aid == article.id {
return article.name
}
for child in article.children {
if aid == child.id {
return child.name
}
}
}
return ""
}
articleList is array of that Article mappable class.
Now when i loop in children, i get this error:
Value of type 'Article' has no member 'Generator'
How can i loop in children array?
[], thanks..