How to delete a row from UITableView? [duplicate] - ios

This question already has answers here:
How to delete a row from UITableView
(5 answers)
Closed 9 years ago.
I want to delete a row from a tableView by using alertView message to confirm, but got some error output:
reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
Setup some of private member in SomeViewController interface
#interface SomeViewController ()
{
NSMutableArray *listItems;
NSString *itemId;
NSIndexPath *rowIndexPath;
}
In SomeViewController.m
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [listItems count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[listItems objectAtIndex:section] count];
}
#pragma mark - Table view operation
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//add code here for when you hit delete
UIAlertView *deleteAlert = [[UIAlertView alloc] initWithTitle:#"Message"
message:#"Are you sure?"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:#"Cancel", nil];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
itemId = cell.textLabel.text;
rowIndexPath = indexPath;
deleteAlert.tag = 1;
[deleteAlert show];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == 1)
{
if (buttonIndex == 0) {
NSLog(#"itemId: %#", itemId);
NSLog(#"rowIndexPath: %#", rowIndexPath);
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:rowIndexPath]
withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
[self.tableView reloadData];
}
}
}
I can correctly set the tableView data and show deletion option, but can't figure it out why that error occurred.

Delete the datasource before you delete cell.
Hope it helps
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == 1)
{
if (buttonIndex == 0) {
NSLog(#"itemId: %#", itemId);
NSLog(#"rowIndexPath: %#", rowIndexPath);
[self.tableView beginUpdates];
[[listItems objectAtIndex:section] removeObjectAtIndex:rowIndexPath.row]
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:rowIndexPath]
withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
[self.tableView reloadData];
}
}

Remember every time you do a delete action, you should always modify your data source first.

You can simply remove the object from the array, then reload the UITableView. Like So:
[YourArray removeObjectAtIndex:1]; //Change the index to which cell you want to "delete"
[YourTableView reloadData];
Or do as stated here: How to delete a row from UITableView.

Related

How to add/insert a new row in UITableView using user input

self.alphabets is my data source which contains all the alphabets.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{ [tableView beginUpdates];
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.alphabets removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationFade];
}
if (editingStyle == UITableViewCellEditingStyleInsert) {
[self.alphabets insertObject:[self.alphabets objectAtIndex:indexPath.row] atIndex:[self.alphabets count]-1];
NSIndexPath * path1 = [NSIndexPath indexPathForRow:indexPath.row inSection:0];
NSArray * index = [NSArray arrayWithObjects:path1, nil];
[self.tableView insertRowsAtIndexPaths:index withRowAnimation:UITableViewRowAnimationAutomatic];
}
[tableView endUpdates];
NSLog(#"%#",self.alphabets);
}
This is the code, which i am using to add or insert rows/cells in tableview by using the data already present.
But i want to add or insert a new row/cell by taking the user input. How to do it.
I have tried to use UIAlertController. Is that a right approach? But i failed. Someone please help me.
Also, i have a doubt about inserting multiple rows at a time. How to achieve it.
Here is the code which i am using to insert multiple rows at a time.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView beginUpdates];
if (editingStyle == UITableViewCellEditingStyleInsert) {
[self.alphabets insertObject:[self.alphabets objectAtIndex:indexPath.row] atIndex:[ self.alphabets count]-1];
NSIndexPath * path1 = [NSIndexPath indexPathForRow:indexPath.row inSection:0];
NSIndexPath * path2 = [NSIndexPath indexPathForRow:indexPath.row+1 inSection:0];
NSArray * index = [NSArray arrayWithObjects:path1,path2, nil];
[self.tableView insertRowsAtIndexPaths:index withRowAnimation:UITableViewRowAnimationAutomatic];
}
[tableView endUpdates];
NSLog(#"%#",self.alphabets);
}
Here is the exception i am getting.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (11) must be equal to the number of rows contained in that section before the update (10), plus or minus the number of rows inserted or deleted from that section (2 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleInsert) {
UIAlertController * alert = [UIAlertController alertControllerWithTitle:#"Inserting a new row" message:#"Enter text below to add it to table view" preferredStyle:UIAlertControllerStyleAlert];
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
}];
UIAlertAction * ok = [UIAlertAction actionWithTitle:#"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSArray * tfArray = alert.textFields;
UITextField * tf = [tfArray objectAtIndex:0];
self.userInput = tf.text;
NSLog(#"%#",self.userInput);
[self.alphabets insertObject:self.userInput atIndex:indexPath.row];
[tableView reloadData];
}];
[alert addAction:ok];
[self presentViewController:alert animated:NO completion:nil];
}
NSLog(#"%#",self.alphabets);
}
Using the above code, I am able to add or insert new rows or cells with user input.
I used a UIAlertController to complete this task. I added a UITextfield to the alert controller and can now get input from it. It in turn adds it to the datasource and the reloaded UITableview.
self.userInput is an string used to store the user input given through a textfield in an alert.
If anyone thinks that this code can be improved, then let me know. I am always willing to improve myself.

UITableView reloadData with empty array

I am deleting all the items in UITableView. And thus the array from which I am loading the UITableView has count = 0. After deleting the last item in array, on reloading the table, I am getting error at numberofRowInSection.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [arrProjects count];
}
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"");
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[tableProject beginUpdates];
Project *project = [arrProjects objectAtIndex:indexPath.row];
[[CommonModel shared]DeleteProjectDetails:project.ProjectId];
[arrProjects removeObject:project];
[self reloadTableProject:YES];
[tableProject endUpdates];
}
}
-(void) reloadTableProject:(BOOL)isReloadRequired
{
//[arrProjects removeAllObjects];
arrProjects = [[CommonModel shared]GetAllProjects];
if(isReloadRequired)
[tableProject reloadData];
}
This is the error :
'Invalid update: invalid number of rows in section 0. The number of
rows contained in an existing section after the update (1) must be
equal to the number of rows contained in that section before the
update (2), plus or minus the number of rows inserted or deleted from
that section (0 inserted, 0 deleted) and plus or minus the number of
rows moved into or out of that section (0 moved in, 0 moved out).'
I am getting this error every time, not only when the array is empty.
Set :
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [_datasourceArray count];
}
To empty your TableView, do :
[_datasourceArray removeAllObjects];
[_tableView reloadData];
You need to remove the object from arrProjects too, inside UITableViewCellEditingStyleDelete,
[arrProjects removeObjectAtIndex:indexPath.row];
it is also good to include
[self.tableView beginUpdates] and [self.tableView endUpdates]
when you start and end the removal of these objects
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [arrProjects count];
}
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"");
if (editingStyle == UITableViewCellEditingStyleDelete)
{
Project *project = [arrProjects objectAtIndex:indexPath.row];
[[CommonModel shared]DeleteProjectDetails:project.ProjectId];
[arrProjects removeObject:project.ProjectId];
[self reloadTableProject: YES];
}
}

Why am I getting an assert Error When trying to Delete a section in a tableview ios

I have a tableView with some sections, which all have a footer, and then I have a tableViewFooter on the Tableview itself.
If I scroll down to the bottom of my tableview and delete the last item(therefore deleting the section altogether) in any sections above the last section (second last and up) it gives me this error
2014-02-21 13:19:55.066 xxxx[5436:60b] *** Assertion failure in -[UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing:], /SourceCache/UIKit/UIKit-2903.23/UITableViewSupport.m:2661
Uncaught exception: Cell animation stop fraction must be greater than start fraction
at endUpdates
this is my code
[self.tableView beginUpdates];
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
if(indexPath != nil){
TableSection * sec = [self.sections objectAtIndex:indexPath.section];
NSMutableDictionary *dic =[sec.items objectAtIndex:indexPath.row];
Product* product = [dic valueForKey:PRODUCT];
//removing the item in the section
[sec.items removeObject:dic];
//deleting item from products
NSMutableArray *temp = [NSMutableArray array];
for (Product *p in self.dataCon.listPersister.products) {
if ([p.product.objId isEqualToString: product.product.objId]) {
[temp addObject:p];
}
}
for (Product *p in temp) {
[self.dataCon.listPersister.products removeObject:p];
}
//if it was the last object in section, delete the section else just delete the single row
if(sec.items.count == 0)
{
[self.sections removeObject:sec];
[self.footers removeObjectAtIndex:indexPath.section];
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationFade];
} else
{
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
USFooterView *footer = [self.footers objectAtIndex:indexPath.section];
footer.totalLabel.text = [self.dataCon.listPersister getTotalForShopId:sec.title];
self.footerView.totalLabel.text = [self.dataCon.listPersister getTotalForAllProducts];
}
}
[self.tableView endUpdates];
I had the same code earlier, just without my tableView and table sections having footers, where it worked, so I think they might be the problem, but I'm not entirely sure that's the reason it's acting up.
I have seen this post
UITableView tableFooterView may cause crash?
And the post that it links to, but that didn't help me.
Any help is appreciated :)
In the else statement you delete row from table view:
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
But not from data source. Delete row from array which you use as data source and it should works.
I found a "fix", but I'm avoiding the use of sectionFooter, because that seems to be bugged.
I created an extra cell at the end of each section, with the same setup I had for my footer View before, and made that last cell not editable with
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
TableSection * sec = [self.sections objectAtIndex:indexPath.section];
if (sec.items.count != indexPath.row) {
return YES;
} else
return NO;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [sec.items count] +1 ;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"normalcell";
static NSString *CellIdentifier1 = #"footercell";
TableSection * sec = [self.sections objectAtIndex:indexPath.section];
if (indexPath.row != sec.items.count) {
//use normal type of cell
return cell;
} else{
//use footer type of cell
return cell;
}
}
So the last cell Imitates a "footer", but it's not stuck to the bottom of the frame, but I'll have to live with that. It's better than crashes.
Try using UITableViewRowAnimationLeft or UITableViewRowAnimationRight as the delete row animation(deleteRowsAtIndexPaths:withRowAnimation:).
It crashed for me when using UITableViewRowAnimationAutomatic, but not with the other two. I have not tried all of them but it seems to be a bug with the animation code for some of the options.

ios6 remove last cell in section causing error

I am getting this error when deleting the last row in the section of a UITableView.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (2) must be equal to the number of sections contained in the table view before the update (3), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'
My table has 3 sections IF an array has a count above 0 (users can add locations themselves). If the array is equal to 0 then the table contains only 2 section, which is where I think the problem lies, I just can't figure it out.
The code I have for deleting the cells and updating the arrays is:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* delCell = [tableView cellForRowAtIndexPath:indexPath];
delName = delCell.textLabel.text;
[self deleteLocation];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
-(void)deleteLocation {
NSLog(#"Name = %#",delName);
NSUserDefaults *customLocations = [NSUserDefaults standardUserDefaults];
NSUserDefaults *sharedPref = [NSUserDefaults standardUserDefaults];
[customLocations removeObjectForKey:delName];
[customLocations synchronize];
[customLoc removeObject:delName];
saveCustomLoc = [NSArray arrayWithArray:customLoc];
[sharedPref setObject:saveCustomLoc forKey:#"CustomLocations"];
[sharedPref synchronize];
NSLog(#"%#",saveCustomLoc);
NSLog(#"%lu",(unsigned long)[saveCustomLoc count]);
[self showAlert];
}
- (void) showAlert {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Location Deleted"
message:#"The location has been deleted"
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
This works great until the final cell.
An example of how my table is set up is:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
if ([customLoc count] == 0) { // If there is no data in the custom locations array the don't include that section
if (section == 0) {
return [serverSelection count];
}
else {
return [qServerSelection count];
}
}
else {
if (section == 0) {
return [customLoc count];
}
else if (section == 1) {
return [serverSelection count];
}
else {
return [qServerSelection count];
}
}
So the headings/number of rows/number of sections etc. is dependent on the contents of an Array. The fact that the section the cells are being removed from disappears (or rather suddenly has 4 cells in as section 1 moves to section 0) I think is causing the issue.
Any ideas how to work around this?
After looking into this some more I found out (with the help of some Apple forum members) that when removing the last row from a section you also need to explicitly delete the section as well.
I also added table update code at the beginning and the end as shown below:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView beginUpdates];
UITableViewCell* delCell = [tableView cellForRowAtIndexPath:indexPath];
delName = delCell.textLabel.text;
[self deleteLocation];
if ([customLoc count] == 0) {
[tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];
}
else {
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
[tableView endUpdates];
}
So, if my array is 0 (in effect the last row is being deleted) the section itself is removed.

Dynamically add rows to multiple sections in grouped table

I've dug through and found several examples of dynamically adding rows to a UITableView just not to a grouped table and I just can't figure this out. I know what I want to do - I have a grouped table with 3 sections. I want to dynamically add an 'Add new item' row/cell to sections 1 and 2 but not 0 when the edit button is selected.
First I'm confused about numberOfRowsInSection. I'm initially loading my table with this.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[[tableData objectAtIndex:section] objectForKey:#"Rows"] count];
}
Do I need to add an if statement for when I'm editing to add a row to the count for those sections when I'm editing? such as:
if (editing) {
return [[[tableData objectAtIndex:section] objectForKey:#"Rows"] count] + 1;
}
And I realize that the above, if correct, would add a row to each section not just 1 and 2. How would I limit that?
Next is my setEditing function. This is where my real problem is. I believe I need to make an array of index paths of the last rows of sections 1 and 2 so that I can insert the new rows below them. The below is wrong, just my experimentation trying to get something inserted somewhere.
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:animated];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:1];
NSMutableArray* paths = [[NSMutableArray alloc] initWithObjects:indexPath, nil];
NSArray *paths = [NSArray arrayWithObject:
[NSIndexPath indexPathForRow:6 inSection:1]];
if (editing) {
[[self tableView] insertRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop]; }
else {
[[self tableView] deleteRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop]; }
}
That crappy code returns this error:
Invalid update: invalid number of rows
in section 1. The number of rows
contained in an existing section after
the update (5) must be equal to the
number of rows contained in that
section before the update (5), plus or
minus the number of rows inserted or
deleted from that section (1 inserted,
0 deleted).
So I'm a bit lost. IndexPaths and Arrays are new to me. Actually it's all new to me and I do pour over the docs and posts here but I can't say I always understand it. Any help would be appreciated. I also do realize that I still need to configure my cell and commitEditingStyle methods but I think I can figure that out if I can get a handle on understanding index paths and arrays.
thanks
-----EDIT-----
Ok, so I got this for the most part. I've added a new row to my sections when editing:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(self.editing && section != 0) {
int rows = 0;
rows = [[[tableData objectAtIndex:section] objectForKey:#"Rows"] count] + 1;
return rows;
}
else {
int rows = 0;
rows = [[[tableData objectAtIndex:section] objectForKey:#"Rows"] count];
return rows;
}
}
I've figured out how to apply a label to those new rows when in editing mode:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier= #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//configure the cell...
if(self.editing && indexPath.section != 0 && (indexPath.row == [[[tableData objectAtIndex:indexPath.section] objectForKey:#"Rows"] count])) {
cell.textLabel.text = #"Add new Item";
return cell;
}
else
cell.textLabel.text = [[[tableData objectAtIndex:indexPath.section] objectForKey:#"Rows"] objectAtIndex:indexPath.row];
return cell;
And I'm properly setting the last row of my two sections where the row was added to style insert:
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0)
//Can't edit the items in the first section
return UITableViewCellEditingStyleNone;
else
//if it's the last row in sections 1 or 2 make it an Insert item
if(self.editing && indexPath.section != 0 && (indexPath.row == [[[tableData objectAtIndex:indexPath.section] objectForKey:#"Rows"] count])) {
return UITableViewCellEditingStyleInsert;
}
//Everything else in sections 1 or 2 should be Delete style
else
return UITableViewCellEditingStyleDelete;
}
That all works. Of course it doesn't animate and I still need help with that. I think, but I'm not certain that I need to do the insert/delete rows from the setEditing method. What I believe I need to do is make an array to the sections that I'm editing and then insert the rows there. The *paths array below is wrong because I need an array that points to the last rows in sections 1 & 2 and I don't know how to create that array. Or maybe everything I'm thinking is just wrong. Can someone help point the way? Much thanks.
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[self.tableView setEditing:editing animated:animated];
NSArray *paths = [NSArray arrayWithObject:
[NSIndexPath indexPathForRow:?? inSection:??]];
if (editing) {
[[self tableView] insertRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop]; }
else {
[[self tableView] deleteRowsAtIndexPaths:paths
withRowAnimation:UITableViewRowAnimationTop]; }
}
Do I need to add an if statement for when I'm editing to add a row to the count for those sections when I'm editing?
Yes, in your tableView:numberOfRowsInSection: method, you should return count + 1 in the editing mode. If you do not want to add a row to section 0 then adjust your if condition, i.e.
if( self.editing && section != 0)
Your second problem is related to the first one. You are inserting a new row to the section 1 but
numberOfRowsInSection still returns 5 for that section. It should return 6.
The methods insertRowsAtIndexPaths:withRowAnimation: and deleteRowsAtIndexPaths:withRowAnimation:
are just to reload the table efficiently and with animation. I suggest you to implementsetEditing:animated function as below for now. Then you should implement your tableView:numberOfRowsInSection: and tableView:cellForRowAtIndexPath: methods by taking editing state into account. After everything is working properly, you can use insert and delete methods to have more control over which parts of the table are reloaded.
- (void)setEditing:(BOOL)editing animated:(BOOL)animated{
[super setEditing:editing animated:animated];
[self.tableView reloadData];
}
--EDIT--
You are in the correct path. You can get the indexPaths to delete/insert with a code similar to below:
NSArray *paths = [NSArray arrayWithObjects:
[NSIndexPath indexPathForRow:[[[tableData objectAtIndex:1] objectForKey:#"Rows"] count] inSection:1],
[NSIndexPath indexPathForRow:[[[tableData objectAtIndex:2] objectForKey:#"Rows"] count] inSection:2],
nil
];

Resources