0

How do I add UITableView in UITableViewCell, the UITableView in each UITableViewCell is with different data?

How to show this json in UITableView:

"DiviDeta": [
                          {
                            "Id": 12453,
                            "Nombre": "BATIDO",
                            "Precio": 1800,
                            "Sabores": [
                              {
                                "Id": 564,
                                "Nombre": "FEIJOA"
                              },
                              {
                                "Id": 565,
                                "Nombre": "GUANABANA"
                              },
                              {
                                "Id": 562,
                                "Nombre": "LULO"
                              },
                              {
                                "Id": 561,
                                "Nombre": "MANGO"
                              },
                              {
                                "Id": 566,
                                "Nombre": "MARACUYA"
                              },
                              {
                                "Id": 563,
                                "Nombre": "MORA"
                              }
                            ]
                          }
Jasper
  • 7,031
  • 3
  • 35
  • 43
Andres Marin
  • 251
  • 3
  • 12

1 Answers1

1

I have done it before but not in swift, in Objective C.

Below are steps to add TableView on TableviewCell:

  1. Make TableView Cell class with xib.

@interface CollapsableCell_iPhone : UITableViewCell <UITableViewDelegate,UITableViewDataSource>

  1. Add View on content view.on that view add tableview and set delegates to tableview cell class.

enter image description here

  1. Implement delegate method inside tableview cell class.

  2. Use this cell in Your Tableview as many time as required.

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CollapsableCell_iPhone" owner:self options:nil];
    
    CollapsableCell_iPhone *cell = (CollapsableCell_iPhone *)[nib lastObject];
    
Shamas S
  • 7,507
  • 10
  • 46
  • 58
Abbas Mulani
  • 703
  • 2
  • 8
  • 19
  • this is in Objective-C http://stackoverflow.com/questions/17398058/is-it-possible-to-add-uitableview-within-a-uitableviewcell but no en Swift – Andres Marin May 26 '15 at 15:34