wouter
(wouter)
1
Ok this should be very easy but im having a little trouble solving this although i feel it should be very obvious 
I have a UITable which get filled dynamically.
I can manually initialise the data with:
self.mydata = [TableCell.init(parent: "dd1", maintit: "d2d", comment: "dd3"),TableCell.init(parent: "dd1", maintit: "d2d", comment: "dd3")]
now i want to do the same thing but then fill it from an array.
I tried putting it inside my array but then i only get the last value which makes sense. Normally i would change it into self.mydata.append but this throws an error.
for (index, interesses) in response.comp.enumerated() {
self.mydata = [TableCell.init(parent: interesses.parentname, maintit: interesses.name, comment: interesses.comments)]
}
self.mydata = response.comp.map { value in
TableCell(
parent: value.parentname,
maintit: value.name,
comment: value.comments
)
}
1 Like
The imperative way, though less efficient for large arrays
for interesses in response.comp {
self.myData.append(
TableCell(
parent: interesses.parentname,
maintit: interesses.name,
comment: interesses.comments
)
)
}
1 Like