2016-12-01 52 views
-1

我在Alamofire 4.0在nsmutabledictionary中保存響應? SWIFT 3.0

Alamofire.request(webpath).responseJSON 
    { 
     response in 

     //here I want to store response in nsmutabledictionary 
    } 

這些響應中獲得響應代碼,我有數據對象,其中包含像下面

{"Success":"True","Data":[{"Id":"4","Name":"xyz"}] 

我想保存數據對象NSMutableArray數據在UITableview

+1

一如既往不要在Swift中使用'NSMutable ...',除非你絕對沒有選擇。在這裏,你有。 – vadian

回答

1

顯示你可以從這樣Alamofire響應結果Dictionary

Alamofire.request(webpath).responseJSON 
{ 
    response in 

    switch(response.result) { 
    case .success(_): 
     if let dic = response.result.value as? [String: Any], 
      let array = dic["Data"] as? [[String: Any]] { 
      print(array) 
     } 
    case .failure(_): 
     print(response.result.error) 
    } 
} 

注:使用SWIFT本地DictionaryArray代替NSDictionaryNSArray