i'm new to iOS programming, i want to save the text entered inside a text box placed inside a dynamic table cell where the table cell contents are like accordion.
in view controller table view with 3 dynamic prototype cells are used each cell is named as header,regular and selected respectively and in view controller i used the following code
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell * cell = nil;
switch (indexPath.row) {
case 0:
{
cell = [tableView dequeueReusableCellWithIdentifier:#"Header"];
}
break;
default:
{
NSArray * innerData = [self.data objectAtIndex:indexPath.row - 1];
if(indexPath.row == self.selectedIndex)
{
SelectedCell * tmpCell = (SelectedCell *)[tableView dequeueReusableCellWithIdentifier:#"Selected"];
[tmpCell.label1 setText:[NSString stringWithFormat:#"%#", [innerData objectAtIndex:0]]];
cell = tmpCell;
tmpCell.textLabel.numberOfLines=2;
}
else
{
RegularCell * tmpCell = (RegularCell *)[tableView dequeueReusableCellWithIdentifier:#"Regular"];
[tmpCell.label1 setText:[NSString stringWithFormat:#"%#", [innerData objectAtIndex:0]]];
cell = tmpCell;
tmpCell.textLabel.numberOfLines=2;
}
}
break;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 0)
return;
if(indexPath.row != self.selectedIndex && self.selectedIndex > 0)
{
// Selected different row while there is another selected row
int oldIndex = self.selectedIndex;
self.selectedIndex = indexPath.row;
NSArray * innerData = [self.data objectAtIndex:oldIndex - 1];
[self.data removeObjectAtIndex:oldIndex - 1];
NSIndexPath * deselectedIndexPath = [NSIndexPath indexPathForRow:oldIndex inSection:0];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deselectedIndexPath] withRowAnimation:UITableViewRowAnimationNone];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.0 * NSEC_PER_SEC),
dispatch_get_main_queue(),
^{
[self.data insertObject:innerData atIndex:deselectedIndexPath.row - 1];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:deselectedIndexPath] withRowAnimation:UITableViewRowAnimationTop];
[tableView reloadData];
NSArray * innerData = [self.data objectAtIndex:indexPath.row - 1];
[self.data removeObjectAtIndex:indexPath.row - 1];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC),
dispatch_get_main_queue(),
^{
[self.data insertObject:innerData atIndex:indexPath.row - 1];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];
[tableView reloadData];
});
});
}
else
{
if(indexPath.row == self.selectedIndex) // selected active row -> close
self.selectedIndex = -1;
else // selected inactive row -> open
self.selectedIndex = indexPath.row;
NSArray * innerData = [self.data objectAtIndex:indexPath.row - 1];
[self.data removeObjectAtIndex:indexPath.row - 1];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC),
dispatch_get_main_queue(),
^{
[self.data insertObject:innerData atIndex:indexPath.row - 1];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];
[tableView reloadData];
});
}
}
now i want to store the text entered in each field specific to that cell i searched a lot of tutorials but i could not find it
please provide me with suitable solution ASAP
thanks in advance
Related
I am adding a filter function to my app, but every time a filter is applied a previously opened cell does not close when I change the filter, is there a way to implement this?
I am currently using:
[self.tableview reloadData];
to reload the table every time the filter is applied
To open and close:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self tableView:tableView canCollapseSection:indexPath.section])
{
if (!indexPath.row)
{
// only first row toggles exapand/collapse
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSInteger section = indexPath.section;
BOOL currentlyExpanded = [expandedSections containsIndex:section];
NSInteger rows;
NSMutableArray *tmpArray = [NSMutableArray array];
if (currentlyExpanded)
{
rows = [self tableView:tableView numberOfRowsInSection:section];
[expandedSections removeIndex:section];
}
else
{
[expandedSections addIndex:section];
rows = [self tableView:tableView numberOfRowsInSection:section];
NSLog(#"Section:%d", rows);
}
for (int i=1; i<rows; i++)
{
NSIndexPath *tmpIndexPath = [NSIndexPath indexPathForRow:i
inSection:section];
NSLog(#"INDEX: %#", tmpIndexPath);
[tmpArray addObject:tmpIndexPath];
}
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (currentlyExpanded)
{
dispatch_async(dispatch_get_main_queue(), ^{
[tableView deleteRowsAtIndexPaths:tmpArray
withRowAnimation:UITableViewRowAnimationTop];
});
}
else
{
dispatch_async(dispatch_get_main_queue(), ^{
[tableView insertRowsAtIndexPaths:tmpArray
withRowAnimation:UITableViewRowAnimationTop];
});
}
}
}
Before tableview reloadData clear the expandedSections array.
[expandedSections removeAllIndexes];
[self.tableView reloadData];
expandedSections Array maintains the status of the expand section details.Due to that its not collapse the view. So clear the array before reload the table view.
So in my table view, I have an array called dataArray and it's getting its objects from a server using JSON. I added a button to each cell and when the button is clicked the cell is supposed to move to another section/ or another array called followedArray to be more exact. Now the cells are transferring to the other section but after moving 6 cells I get an error that saids this. All arrays are NSMutableArray. Also, I'm new to iOS so try to work with me, thank you.
2016-10-26 17:27:19.569 CustomCellApp[3212:198103] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 4]'
---------------------
Side note, I can make a separate error post but I have another issue, the images displaying in the cells are being changed to other images when switching sections, using the pod SDWebImage.
---------------------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (!isFiltered) {
if (section == 0) {
return [followedArray count];
}
else if (section == 1) {
return [dataArray count];
}
}
return [filteredArray count];
}
---------------------
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0) {
return #"Followed Data";
}
else {
return #"All Data";
}
}
---------------------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configuring the cell
Data * dataObject;
if (!isFiltered) {
if (indexPath.section == 0) {
dataObject = [followedArray objectAtIndex:indexPath.row];
}
else if (indexPath.section == 1) {
dataObject = [dataArray objectAtIndex:indexPath.row];
}
}
else {
dataObject = [filteredArray objectAtIndex:indexPath.row];
}
// Loading Images
if (!isFiltered) {
// Exception Breakpoint Here
NSURL * imgURL = [[dataArray objectAtIndex:indexPath.row] valueForKey:#"dataURL"];
[cell.myImageView setContentMode:UIViewContentModeScaleAspectFit];
[cell.myImageView sd_setImageWithURL:imgURL placeholderImage:[UIImage imageNamed:#"no-image.png"] options:SDWebImageRefreshCached];
}else{
NSURL * imgURL = [[filteredArray objectAtIndex:indexPath.row] valueForKey:#"dataURL"];
[cell.myImageView setContentMode:UIViewContentModeScaleAspectFit];
[cell.myImageView sd_setImageWithURL:imgURL placeholderImage:[UIImage imageNamed:#"no-image.png"] options:SDWebImageRefreshCached];
}
// Loading Follow Button
cell.followButton.tag = indexPath.row;
[cell.followButton addTarget:self action:#selector(followButtonClick:) forControlEvents:UIControlEventTouchUpInside];
cell.followButton.hidden = NO;
return cell;
}
---------------------
-(void)followButtonClick:(UIButton *)sender {
// Adding row to tag
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.myTableView];
NSIndexPath *indexPath = [self.myTableView indexPathForRowAtPoint:buttonPosition];
// Creating an action per tag
if (indexPath != nil)
{
// Change Follow to Following
[sender setImage:[UIImage imageNamed:#"follow.png"] forState:UIControlStateNormal];
cell.followButton.hidden = YES;
cell.followedButton.hidden = NO;
// ----- ERROR BEGINS HERE ----- //
[self.myTableView beginUpdates];
// ----- Inserting Cell to Section 0 ----- *CAUSING PROBLEMS*
// Exception Breakpoint Here
[followedArray addObject:[dataArray objectAtIndex:indexPath.row]];
[myTableView insertRowsAtIndexPaths:#[[NSIndexPath indexPathForRow:followedArray.count-1 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
NSLog(#"indexPath.row = %ld", (long)indexPath.row);
// ----- Removing Cell from Section 1 ----- *WORKING*
[dataArray removeObjectAtIndex:indexPath.row];
NSInteger rowToRemove = indexPath.row;
[self.myTableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObjects:[NSIndexPath indexPathForRow:rowToRemove inSection:1], nil] withRowAnimation:YES];
NSLog(#"Array =%#",followedArray);
[self.myTableView endUpdates];
// ----- ERROR ENDS HERE ----- //
}
}
---------------------
This is what helped me fix the errors I was having. Credits to #AliOmari for helping me out.
In cellForRowAtIndexPath
// Configuring the cell
Data * dataObject;
if (!isFiltered) {
if (indexPath.section == 0) {
dataObject = [followedArray objectAtIndex:indexPath.row];
[cell populateCell:dataObject isFollowed:YES indexPath:indexPath parentView:self];
}
else if (indexPath.section == 1) {
dataObject = [dataArray objectAtIndex:indexPath.row];
[cell populateCell:dataObject isFollowed:NO indexPath:indexPath parentView:self];
}
}
else {
dataObject = [filteredArray objectAtIndex:indexPath.row];
[cell populateCell:dataObject isFollowed:NO indexPath:indexPath parentView:self];
}
return cell;
Inside my Button
[self.myTableView beginUpdates];
// ----- Inserting Cell to Section 0 -----
[followedArray insertObject:[dataArray objectAtIndex:indexPath.row] atIndex:0];
[myTableView insertRowsAtIndexPaths:#[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
//NSLog(#"indexPath.row = %ld", (long)indexPath.row);
// ----- Removing Cell from Section 1 -----
[dataArray removeObjectAtIndex:indexPath.row];
NSInteger rowToRemove = indexPath.row;
[self.myTableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObjects:[NSIndexPath indexPathForRow:rowToRemove inSection:1], nil] withRowAnimation:YES];
//NSLog(#"Array =%#",followedArray);
[self.myTableView endUpdates];
Here is my custom cell code
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
ContestTableViewCell *cell = [myContestTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *myNib;
myNib =[[NSBundle mainBundle]loadNibNamed:#"ContestTableViewCell" owner:self options:nil];
cell =[myNib objectAtIndex:0];
}
if (selectedIndex==indexPath.row)
{
}
else
{
}
cell.fldExamTitleLbl.text = [fldExamTitleArray objectAtIndex:indexPath.row];
cell.fldExamStartDateLbl.text = [fldExamStartArray objectAtIndex:indexPath.row];
cell.prizeMoney.text =[prizeMoneyArray objectAtIndex:indexPath.row];
cell.firstReward.text = [firstRewardArray objectAtIndex:indexPath.row];
cell.secondReward.text = [secondRewardArray objectAtIndex:indexPath.row];
cell.thirdReward.text = [thirdRewardArray objectAtIndex:indexPath.row];
return cell;
}
And didSelectRowAtIndexPath i am writing this code
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (selectedIndex == indexPath.row)
{
selectedIndex = -1;
[myContestTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
return;
}
if (selectedIndex != -1)
{
NSIndexPath *prevPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
selectedIndex = indexPath.row;
[myContestTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:prevPath] withRowAnimation:UITableViewRowAnimationFade];
}
selectedIndex = indexPath.row;
[myContestTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
I am getting Output like this it is reloading the data of JSON.
I am new to iOS please help me.
I have 1 empty section and other sections with full of objects.I have a button in all rows.when clicked on the button in a row the row should move to the empty section.But I am getting this error saying invalid tableview update.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid table view update. The application has requested an update to the table view that is inconsistent with the state provided by the data source.'
I tried the following Code.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if ([[arrayForBool objectAtIndex:section] boolValue]) {
if(section == 0){
return favouritesArray.count;
}else{
NSString* key = [sectionTitleArray objectAtIndex:section - 1];
NSArray *aArray = [sectionContentDict valueForKey:key];
return aArray.count;
}
}
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = #"UCPMenuCellIdentifier";
UCPCategoryListCell *cell = (UCPCategoryListCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[UCPCategoryListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]autorelease];
}
if(indexPath.section == 0){
cell.textLabel.text = [favouritesArray objectAtIndex:indexPath.row ];
}
else{
NSString* key = [sectionContentDict.allKeys objectAtIndex:indexPath.section - 1];
BOOL manyCells = [[arrayForBool objectAtIndex:indexPath.section] boolValue];
if (!manyCells) {
cell.textLabel.text = #"click to enlarge";
}
else{
cell.textLabel.text = [[sectionContentDict objectForKey:key] objectAtIndex:indexPath.row];
}
}
UIButton *deletebtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
deletebtn.frame=CGRectMake(220, 10, 20, 20);
[deletebtn addTarget:self action:#selector(moveRowToFavorites:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:deletebtn];
return cell;
}
-(void)moveRowToFavorites:(id)sender{
UIButton *button = (UIButton *)sender;
UITableViewCell *cell = (UITableViewCell *)button.superview.superview;
[self.aTableView beginUpdates];
[favouritesArray addObject:cell.textLabel.text];
NSIndexPath *newindexPath = [NSIndexPath indexPathForRow:[favouritesArray count] inSection:0];
NSIndexPath *oldindexPath = [self.aTableView indexPathForCell:cell];
[self.aTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:oldindexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.aTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newindexPath] withRowAnimation:UITableViewRowAnimationRight];
[self.aTableView endUpdates];
}
Try moveRowToFavorites: method like this:
- (void) moveRowToFavorites: (id) sender
{
UIButton* button = (UIButton*) sender;
UITableViewCell* cell = (UITableViewCell*) button.superview.superview;
[self.aTableView beginUpdates];
[favouritesArray addObject: cell.textLabel.text];
NSIndexPath* newindexPath = [NSIndexPath indexPathForRow: [favouritesArray count] - 1
inSection: 0];
[self.aTableView insertRowsAtIndexPaths: [NSArray arrayWithObject: newindexPath]
withRowAnimation: UITableViewRowAnimationRight];
NSIndexPath* oldindexPath = [self.aTableView indexPathForCell: cell];
[self.aTableView deleteRowsAtIndexPaths: [NSArray arrayWithObject: oldindexPath]
withRowAnimation: UITableViewRowAnimationFade];
NSInteger oldSection = oldindexPath.section;
NSInteger oldRow = oldindexPath.row;
NSString* key = [sectionTitleArray objectAtIndex: oldSection - 1];
NSMutableArray* anArray = [NSMutableArray arrayWithArray: [sectionContentDict valueForKey: key]];
[anArray removeObjectAtIndex: oldRow];
[sectionContentDict setValue: anArray forKey: key];
[self.aTableView endUpdates];
}
I created project with this code. It is working fine. If you need I can give.
Hope my code helps you.
In moveRowToFavorites method change arrays(favouritesArray and sectionContentDict). You have added in favouritesArray. Delete same object from other array. Then call table reloadData.
Try this. It will add to favorite section.
-(void)moveRowToFavorites:(id)sender{
UIButton *button = (UIButton *)sender;
UITableViewCell *cell = (UITableViewCell *)button.superview.superview;
[favouritesArray addObject:cell.textLabel.text];
//here you need to delete same object from [sectionContentDict objectForKey:key]
[self.aTableView reloadData];
}
Dont do anything like insertRowsAtIndexPaths or deleteRowsAtIndexPaths
In -(void)moveRowToFavorites:(id)sender after just adding object to favouritesArray, you have to remove objet from array within the sectionContentDict. And you dont have to use [table reloadData] after begin-end Updates.
I need to load the "Main Entity" that has a relationship one-to-many with "Child Entity" into the same UITableView, how can i do?
Thanks in advance.
Update
i use the following code to populate the UITableView:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [[[fetchedResultsController sections] objectAtIndex:section] name];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
if (self.selectedIndexPath) {
return [sectionInfo numberOfObjects] + [self.childArray count];
}else {
return [sectionInfo numberOfObjects];
}
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
OreRecupero *selectedObj=(OreRecupero*)[self.fetchedResultsController objectAtIndexPath:indexPath];
OrarioMainCell *cell = nil;
if (indexPath == self.selectedIndexPath) {
NSUInteger giorniCount = [selectedObj.giorni count];
NSInteger row = indexPath.row;
if (indexPath.row < giorniCount) {
cell = (OrarioMainCell *)[tableView dequeueReusableCellWithIdentifier:#"Cell"];
if (cell == nil) {
cell=(OrarioMainCell *)[[[NSBundle mainBundle]loadNibNamed:#"myCustomCell" owner:self options:nil]objectAtIndex:11];
radiusLabel=[[LabelRadiusAndText alloc]init];
}
UIImageView *bgImage=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:#"fondoCella"]]autorelease];
cell.backgroundView=bgImage;
[df setDateFormat:#"HH:mm"];
cell.textLabel.text = [NSString stringWithFormat:#"%# - %#",[df stringFromDate:selectedObj.oraInizio],[df stringFromDate:selectedObj.oraFine]];
} else {
cell = (OrarioMainCell *)[tableView dequeueReusableCellWithIdentifier:#"DetailCell"];
if (cell == nil) {
cell=(OrarioMainCell *)[[[NSBundle mainBundle]loadNibNamed:#"myCustomCell" owner:self options:nil]objectAtIndex:13];
radiusLabel=[[LabelRadiusAndText alloc]init];
}
GiornoRecupero *giorno = [childArray objectAtIndex:row];
cell.textLabel.text = [NSString stringWithFormat:#"%i", giorno.oreStraordinario];
cell.detailTextLabel.text = [NSString stringWithFormat:#"%i", giorno.durata];
}
} else {
cell = (OrarioMainCell *)[tableView dequeueReusableCellWithIdentifier:#"Cell"];
if (cell == nil) {
cell=(OrarioMainCell *)[[[NSBundle mainBundle]loadNibNamed:#"myCustomCell" owner:self options:nil]objectAtIndex:11];
radiusLabel=[[LabelRadiusAndText alloc]init];
}
UIImageView *bgImage=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:#"fondoCella"]]autorelease];
cell.backgroundView=bgImage;
[df setDateFormat:#"HH:mm"];
cell.orariLbl.text = [NSString stringWithFormat:#"%# - %#",[df stringFromDate:selectedObj.oraInizio],[df stringFromDate:selectedObj.oraFine]];
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
OreRecupero *selectedObj=(OreRecupero*)[self.fetchedResultsController objectAtIndexPath:indexPath];
NSIndexPath *dropDownCellIndexPath = [NSIndexPath indexPathForRow:indexPath.row + 1
inSection:indexPath.section];
//if user tapped the same row twice let's start getting rid of the control cell
if (!self.selectedIndexPath) {
// Show Drop Down Cell
for (GiornoRecupero *giorno in selectedObj.giorni) {
[self.childArray addObject:giorno];
}
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:dropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationTop];
self.selectedIndexPath = indexPath;
} else {
NSIndexPath *currentdropDownCellIndexPath = [NSIndexPath indexPathForRow:self.selectedIndexPath.row + 1
inSection:self.selectedIndexPath.section];
if (indexPath.row == self.selectedIndexPath.row) {
// Hide Drop Down Cell
[self.childArray removeAllObjects];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:currentdropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationTop];
self.selectedIndexPath = nil;
} else if (indexPath.row == currentdropDownCellIndexPath.row) {
// Dropdown Cell Selected - No Action
return;
} else {
// Switch Dropdown Cell Location
[self.myTableView beginUpdates];
// Hide Dropdown Cell
[self.childArray removeAllObjects];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:currentdropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
// Show Dropdown Cell
NSInteger dropDownCellRow = indexPath.row + ((indexPath.row >= currentdropDownCellIndexPath.row) ? 0 : 1);
dropDownCellIndexPath = [NSIndexPath indexPathForRow:dropDownCellRow
inSection:indexPath.section];
for (GiornoRecupero *giorno in selectedObj.giorni) {
[self.childArray addObject:giorno];
}
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:dropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
self.selectedIndexPath = [NSIndexPath indexPathForRow:dropDownCellIndexPath.row - 1
inSection:dropDownCellIndexPath.section];
[self.myTableView endUpdates];
}
}
}
i would like to insert new rows using didSelectRowAtIndexPath method, getting data from "Child Entity"