I have a classe named \"whisky builder\" which only initiates the new Whisky. Now i would like to add the new added whiskies in my \"WhiskyOverViewController\". But I face t
The two types must be incompatible with each other. Just like you cannot assign a UIImage to a String, your program won't let you assign a [WhiskyBuilder]
array type to a WhiskyOverViewController
type. You must have declared stringArray
globally, because otherwise Swift would infer its type.
What you need there is a read only computed property:
var stringArray: [String] {
return whiskyArray.map{$0.whiskyName!}
}
You need to move this code to a function:
let stringArray = whiskyArray.map({$0.whiskyName!})