下面是代碼,無法將類型的值「JSON」預期參數類型「JSON」
//Controller.swift
struct MyObject {
init(myJson: JSON) {
// some code here
}
}
//unittest.swift
let json = JSON("{}")
let obj = MyObject(myJson: json)
我得到的錯誤Cannot convert value of type 'JSON' to expected argument type 'JSON'
注:但是,這不,當我把發生該結構在相同的單元測試文件中。使用SwiftyJSON庫進行JSON解析