Instance member cannot be used on type of custom class

半城伤御伤魂 提交于 2019-11-26 21:10:39

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!})

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!