I'm trying to create a table with dynamic data, and I'm kind of stuck. Here's how my data is structured:
NSMutableArray *bigArray;
bigArrayhas many elements NSDictionary.
each itemshas only one entry.
sectionName is the key, the value of NSMutableArray.
There valueare many objects in NSMutableArray.
I tried to explain it as simple as possible, here is the part that I'm stuck in.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [bigArray count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[[[bigArray objectAtIndex:section] allValues] objectAtIndex:0] count];
}
I cannot understand this part, how to implement this method based on my current data structure:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"MyCell"];
MyObject *obj =
cell.textLabel.text = obj.name;
return cell;
}
Simply put, I'm trying to insert dynamic sections with dynamic data. I am looking for advice from more experienced developers, how would you handle this?
source
share