Hi,
I use coredata to fill an array with data that is displayed in a tableview. In the tableview, I have two section. When a cell is pushed in section1, I want that cell to be moved to section2, and the other way around.
Im not quite sure how to accomplish this, and I been sitting trying to figure it out for about 8 hours now.
This is what I got so far:
I use this code to get the data:
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"creationDate" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:&sortDescriptor count:1];
NSMutableArray *sortedIngredients = [[NSMutableArray alloc] initWithArray:[event.tags allObjects]];
[sortedIngredients sortUsingDescriptors:sortDescriptors];
self.tagsArray = sortedIngredients;
[sortDescriptor release];
[sortDescriptors release];
[sortedIngredients release];
In didSelectRowForIndexPath, I figure out how to remove the cell:
Tag *tag = [tagsArray objectAtIndex:indexPath.row];
NSManagedObjectContext *context = event.managedObjectContext;
[context deleteObject:tag];
[tagsArray removeObject:tag];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
How do I insert this cell in section 2 in the tableView? Should I create 2 arrays? I tried some code that used NSDictiorary, like this:
[tableView addObject: sectionOneObject forKey:@"Section1"];
[tableView addObject: sectionTwoObjects forKey: @"Section2"];
But I never manage to get it to work.
Any help would be highly appreciated! Thanks in advance