爲什麼我使用Array.contains(AnyObject)來檢查此數組中是否存在結構對象。它使錯誤:「無法轉換的...拋型 - >布爾」Swift:數組包含(AnyObject)錯誤無法轉換類型...... throw - > Bool
struct DecorationPatternsData {
let patternImageName: String
init(patternImageName: String) {
self.patternImageName = patternImageName
}
}
var decorationPatterns : [DecorationPatternsData] = [DecorationPatternsData(patternImageName: "decoration1.gif"), DecorationPatternsData(patternImageName: "decoration1.gif"), DecorationPatternsData(patternImageName: "decoration1.gif")]
var pickedDecorationPattern : DecorationPatternsData? = nil
...
if (pickedDecorationPattern != nil) {
if (decorationPatterns.contains(pickedDecorationPattern)) {
// Error: Cannot convert type of ... throw -> Bool
}
}