使用SwiftyJSON将数据追加到现有JSON数组

时间:2018-10-17 10:46:48

标签: swift swifty-json

我有一个声明的SwiftyJSON数组,并向其中添加了数据。 JSON数据使用cellForRowAt闭包中的逻辑进行过滤。 我想将数据附加到另一个现有的SwiftyJSON变量中。

var jsonObj: JSON = JSON() // With JSON DATA
var filteredJSON: JSON = JSON() // Data to be added after filtration

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    //..... Used jsonObj data and created a value for 'obj'

    if obj.altitude.wrappedValue > 0 {
        var filtr = JSON(jsonObj[indexPath.row].object)
        filteredJSON.arrayObject?.append(filtr)
    }
    print("filteredJSON:", filteredJSON) // null
}

最后filteredJSON始终返回null

0 个答案:

没有答案
相关问题