Asked 30+ days ago
16 Aug 2017
Views 71
jaman

jaman posted

how to get value of two dimensional mutable array in ios swift

getting the data from api

                                self.data =  parseJSON["data"] as! NSMutableArray



data have mutlidimension array like this

{
          {
            data1 = 20;
            data2 = "description is here son dont worry asdf sfsdfsfdg";
            id = 2;
           } ,
      {
            data1 = 20;
            data2 = "description is here son dont worry asdf sfsdfsfdg";
            id =32; 
           }
}



so now i want to set the data at tableview cell

            
        let mycell:BookTokenTableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell") as! BookTokenTableViewCell
     mycell.amount.text=(self.data[indexPath.row] as! NSMutableArray ).value(forKey: "amount") as! String


but getting error at run time
Mitul Dabhi

Mitul Dabhi
answered Jan 23 '18 20:17

its no two dimensional mutable array but its mutable array contain mutable dictionary ,

so


         let data:NSMutableDictionary = self.data[indexPath.row] as! NSMutableDictionary
        NSLog("%@", data["amount"] as! String);
        
        
       mycell.amount.text = data["amount"] as! String
Edit Answer
Share
Post Answer