iphone - Delete particular row from table view -
In my app, I'm coming to delete particular row from the list view my table view content database and data from database After receiving, I pushed the array. Then I changed an array, here on after I showed the content in the table view. My problem is that when I try to delete the second row of the table view on the second row, the first row of the table view is removed, here I have put in the command editing style method code,
if (editSecurity == UITT ViewingTableDialate) {[savedArray removeObjectAtIndex: indexPath.row]; [SaveTable deleteRowsAtIndexPaths: [NSArray arrayWithObject: [savedArray objectAtIndex: val]] of Sathroanimeshn: UITableViewRowAnimationFade]; NewsObj * [[(UIApplication shared application]]] nsManagedObjectContext]; NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription * entity = [NSEntityDescription EntityForName: @ Managed object contexts in "ArticalDetails": [ SelfknewsObj] [FetchRequest set Antiti: entity]; NSError * error; NSArray * items = [self.newsObj executeFetchRequest: fetchRequest error: & amp; error] [News Obj delete objects: [item Objektotandaks: Indekspathkro] ]; NSLog (@ "Deleted content status% d", indexPath.row); if ([News Changes] & amp;! [News Buzz Save: End Edition] {NSLog (@ "% @", [Details of Error]); [SaveTableRoadData];}
for a reverse array
for (int i = 0; i & lt; [savedArray count] / 2; i ++) {int j = [saved array count] - i - 1; Id temp = [[ [Saved Array Object Index: I] is maintained); [Saved OUR order objectatted index: I with object: [saved array of factoutindex: ja]]; [Avoided order object at index: jay with object: temporary]; [Temp Release]; }
Please help me!
This is your problem:
Objektatindeks remove [savedArray: IndexPath.row]; [SaveTable deleteRowsAtIndexPaths: [NSArray arrayWithObject: [savedArray objectAtIndex: val]] of Sathroanimeshn: UITableViewRowAnimationFade];
Before deleting the row from the table, you can delete the row from the array, but you can tell which line to delete the table row, whatever index Val was before
:
[savedArray removeObjectAtIndex: indexPath.row];
... will be invalid by changing saved ARRA
This code is complex for all useless. You do not need to manually reverse the array, but instead you should provide a type descriptor of the fetch request, so that it can return an already sorted array in that order that you need at this time is. Better yet, you should use the NSFetchedResultsController
which will handle all the complexities of adding and removing data from the table and the data for you.
Comments
Post a Comment