我在单独的swift文件中声明了下面的类
class KeerthanaiArray: NSObject {
var SongTitle: String = String()
var SongLyrics: String = String()
var ESongTitle: String = String()
init(SongTitle: String, SongLyrics:String, ESongTitle: String) {
self.SongTitle = SongTitle
self.SongLyrics = SongLyrics
self.ESongTitle = ESongTitle
}
func match(string:String) -> Bool {
return SongTitle.containsString(string) || ESongTitle.containsString(string)
}
}
但是当我在我的Masterviewcontroller中引用这个类时,它会抛出一条错误消息,指出[Keerthanaiarray]类型的值没有成员'匹配'
以下是我的代码......代码在搜索器声明中失败
var keerthanaiArray = [KeerthanaiArray]()
override func viewDidLoad() {
super.viewDidLoad()
**let searchr = (keerthanaiArray.match(KeerthanaiArray.songTitle.lowercaseString))**
答案 0 :(得分:0)
var keerthanaiArray = [KeerthanaiArray]()
这是实例化KeerthanaiArray
的数组。我认为你要做的是:
var keerthanaiArray = KeerthanaiArray(SongTitle: "Some", SongLyrics: "Text", ESongTitle: "Here")