下面是代码,
//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 解析