Asked 6 years ago
16 Aug 2017
Views 837
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 Nov 30 '-1 00:00

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
Post Answer