Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 如何对json数据进行排序并加载uitable view swift3?_Arrays_Json_Swift_Xcode - Fatal编程技术网

Arrays 如何对json数据进行排序并加载uitable view swift3?

Arrays 如何对json数据进行排序并加载uitable view swift3?,arrays,json,swift,xcode,Arrays,Json,Swift,Xcode,如何加载我的json数据和加载uitable视图我尝试了很多时间,但没有找到结果。这是我的json树 [ { "id": 1, "name": "Leanne Graham", "username": "Bret", "email": "Sincere@april.biz", "address": { "street": "Kulas Light", "suite": "Apt. 556", "city": "Gwe

如何加载我的json数据和加载uitable视图我尝试了很多时间,但没有找到结果。这是我的json树

[
  {
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
    },
    "phone": "1-770-736-8031 x56442",
    "website": "hildegard.org",
    "company": {
      "name": "Romaguera-Crona",
      "catchPhrase": "Multi-layered client-server neural-net",
      "bs": "harness real-time e-markets"
    }
  },
]


有人帮我吗?感谢advance

将代码json转换为数组,然后尝试此代码

  let sortedArray = sortArrayUsingKey(strKey: "id", unSortedArray:unsortarray)

 func sortArrayUsingKey(strKey:String,unSortedArray:NSArray) ->NSArray {

    var tempArray:NSMutableArray = NSMutableArray();
    tempArray = unSortedArray.mutableCopy() as! NSMutableArray;
    let descriptor = NSSortDescriptor(key: strKey, ascending: true);
    tempArray.sort(using: [descriptor]);
    return tempArray as NSArray;
 }

您尝试的内容显示您的代码!你要做什么来显示你的代码