Delete selected row - not last saved row?

Up vote 0 down vote favorite share g+ share fb share tw.

App like a calender I want to delete specific rows in my tableView. Each row is saved by a datepicker. The Title und Subtitle is perfekt.

It shows the Name and the time selected in datePicker. If I create more than one event, my tableView shows it in the correct order. Event Nr.1 - 11:00 h Event 2 - 11:10 h so on Also if I create the event in mixed intervals at first 11:10h than 11:00h But If I want to delete the Event Nr.1 it deletet Event Nr.2 It seems that my code deleted always the last saved event.

Edit mode: - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // If row is deleted, remove it from the list. If (editingStyle == UITableViewCellEditingStyleDelete) { UIApplication sharedApplication cancelLocalNotification:notifcation; notificationsArray removeObjectAtIndex:indexPath. Row; tableView deleteRowsAtIndexPaths:NSMutableArray arrayWithObject:indexPath withRowAnimation:UITableViewRowAnimationLeft; tableview reloadData; } } Tableview: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier autorelease; } // Configure the cell... self.

NotificationsArray = NSMutableArray arrayWithArray:UIApplication sharedApplication scheduledLocalNotifications; notifcation = self. NotificationsArray objectAtIndex:indexPath. Row; //UILocalNotification *notif = notificationsArray objectAtIndex:indexPath.

Row; //NSArray *notificationArray = UIApplication sharedApplication scheduledLocalNotifications; //UILocalNotification *notif = notificationArray objectAtIndex:indexPath. Row; //Was in der Zelle als Titel steht //cell textLabel setText:notifcation alertBody; cell textLabel setText:@"Event"; //cell. DetailTextLabel setText:notif.

FireDate description; NSDateFormatter *dateFormatter = NSDateFormatter alloc init; dateFormatter setDateFormat:@"dd.MM. Yyyy HH:mm"; cell detailTextLabel setText:dateFormatter stringFromDate:notifcation. FireDate; dateFormatter release; return cell; } Thanks for helping me.

Iphone table delete row link|improve this question asked Nov 17 '11 at 10:24webschnecke296 45% accept rate.

Add some lines in your method - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if(tableView. Editing && editingStyle == UITableViewCellEditingStyleDelete) { tableView beginUpdates; UIApplication sharedApplication cancelLocalNotification:notifcation; notificationsArray removeObjectAtIndex:indexPath. Row; // Animate the deletion from the table.

TableView deleteRowsAtIndexPaths:NSArray arrayWithObject:indexPath withRowAnimation:UITableViewRowAnimationLeft; tableView endUpdates; tableView reloadData; } } -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. // UITableViewCellEditingStyleNone; return YES; }.

Thanks Kai for editing.. – Surjit Joshi Nov 17 '11 at 10:50 That doesn't work for me. I create 4 events in this order: 3:00h, 3:10h, 2:15h, 2:30h - the order in my table is rigth with: 2:15h, 2:30h, 3:00h, 3:10h. So if I now klick my edit button and want to delete the event 3:00h the result is, that 3:10 was deleted.

Now I deleted 2:30h, and 3:00h is deleted. Whats wrong? – webschnecke Nov 17 '11 at 13:15 Try to add 1 in indexpath.row.

– Surjit Joshi Nov 18 '11 at 5:58 No, is the same. – webschnecke Nov 18 '11 at 10:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions