Welcome, Guest
Username Password: Remember me

Delegate When Row is Deleted
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Delegate When Row is Deleted

Delegate When Row is Deleted 1 year, 8 months ago #1

I can't get the delegate to fire when the user swipes to delete. I set the tableview delegate to self and use this method.

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 
// If row is deleted, remove it from the list.
NSLog(@"Row is deleted");
 
if (editingStyle == UITableViewCellEditingStyleDelete) {
 
 
[mainDelegate eraseShoe:[[mainDelegate items] objectAtIndex:indexPath.row]];
// Perform remote database delete below
}
 
}



How do I use this delegate?
  • baberuth22
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 2

Re: Delegate When Row is Deleted 1 year, 8 months ago #2

Hey Bryan-

Please note that Sensible TableView overrides all UITableView datasource and delegate methods. SCArrayOfObjectsSection automatically handles all deletions, and in return provides you with an SCTableViewModelDelegate method called tableViewModel:willRemoveRowAtIndexPath:.

What are you trying to achieve?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Delegate When Row is Deleted 1 year, 8 months ago #3

I am syncing data to a web database and I need to delete the item from the web.

It would be great is you could get this working with MSSQL or MySQL.

I'll try tableViewModel:willRemoveRowAtIndexPath:.
  • baberuth22
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 2

Re: Delegate When Row is Deleted 1 year, 7 months ago #4

Is there a possibility to prevent STV from deleting the object which belongs to a cell?
I tried to implement tableViewModel:willRemoveRowAtIndexPath:, but I didn't get STV to not delete the object.

Why not change the return type of this delegate method to BOOL and return NO when the object should not be deleted?
As far as I know, Apple acts similar in various delegate methods.

Or is there an other possibility to achieve this?
  • Patrick
  • OFFLINE
  • Senior Boarder
  • Posts: 49
  • Karma: 3

Re: Delegate When Row is Deleted 1 year, 7 months ago #5

STV approaches deletion using a different concept. If you don't want a cell to be deleted, just set its "editable" property to FALSE. Likewise, if you don't want it to move, you set the "movable" property to FALSE, etc.

We believe that it's better for a cell that shouldn't be deleted not have the delete button appear in the first place, instead of just appearing an nothing happening when the user taps it. Hope this helps.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Delegate When Row is Deleted 1 year, 7 months ago #6

I think you misunderstood that.

I have a Core Data app with a UITabBarController containing two tabs: List and Favorites.

In "List" the user can choose a list element and tap on the button "add to favorite". That sets a property (a BOOL) for the represented object in Core Data.
When I now go to the "Favorites" tab, there will be made a fetch request to get all objects where this BOOL is TRUE an these objects will be presented in the table view.

Now I want to set this BOOL property to FALSE again to remove it from the user's favorites. This should happen, when the user swipes across a cell on a table view in the "Favorites" tab. I do not want to remove this object from the data array (which STV generates internally), I really just want to set this property.

Do you know what I mean?
  • Patrick
  • OFFLINE
  • Senior Boarder
  • Posts: 49
  • Karma: 3
Last Edit: 1 year, 7 months ago by Patrick.
  • Page:
  • 1
  • 2
Time to create page: 1.72 seconds