UA-17470720-3

Jump to content


Photo
- - - - -

Cannot add entity after deleting last entity


  • Please log in to reply
7 replies to this topic

#1 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 14 May 2016 - 08:52 PM

Hello,

 

I am experiencing the following behavior: in a SCTableViewController displaying an entity that has relationships configured, if all entities are deleted using the UI (swipe left, tap "Delete"), after deleting the last entity, the "+" button to add a new entity does not do anything. If I restart the app the "+" button works as expected. If the entity does not have relationships configured this behavior does not occur. If the "+" button is tapped after deleting an entity that is not the last one this behavior does not occur.

 

Any suggestions would be greatly appreciated.

 

Thank you!



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 14 May 2016 - 09:34 PM

Hi Radu,

 

Are you using an SCArrayOfObjectsSection or an SCArrayOfObjectsModel?



#3 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 14 May 2016 - 09:56 PM

SCArrayOfObjectsModel



#4 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 15 May 2016 - 02:53 PM

Hi Tarek,

 

Will it make a difference if I'm using an SCArrayOfObjectsSection or an SCArrayOfObjectsModel? I'll try to use SCArrayOfObjectsSection just to see if that makes a difference, but I used SCArrayOfObjectsModel because I need grouping.

 

Any other suggestion on where to look and how to troubleshoot that I would greatly appreciate it.

 

Thank you!



#5 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 15 May 2016 - 05:49 PM

Hi Tarek,

 

I can confirm that I only see this happening with SCArrayOfObjectsModel - any way I can get around this behavior?

 

Thank you!



#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 15 May 2016 - 07:57 PM

Hi Radu,

 

This seems to be some kind of weird bug on our part. We'll be fixing that in our next release (planned in about a couple of weeks from now). Also please let me know if it's urgent and I can issue you a patch in a few days.



#7 RaduGrama

RaduGrama

    Jr. Member

  • STV 5.0 Pro
  • PipPip
  • 29 posts
  • LocationTampa, FL
Reputation: 6
Good

Posted 16 May 2016 - 07:20 AM

Hi Tarek,

 

I noticed that if I explicitly define the delete functionality in tableViewModel.cellActions.editActions, all works as expected:

 

        self.tableViewModel.cellActions.editActions = {
            (cell, indexPath) in
            
            let deleteButton = UITableViewRowAction(style: .Default, title: "Delete", handler: {
                (action, indexPath) in
                
                if let itemsSection = cell.ownerSection as? SCArrayOfItemsSection
                {
                    itemsSection.dispatchEventRemoveRowAtIndexPath(indexPath)
                }
            })
            
            return [editButton]
        }
 
Considering the above, if the fix you mentioned is different I would probably want it, my app will most likely go live in the next couple of weeks.
 
Thank you!

Edited by RaduGrama, 16 May 2016 - 07:21 AM.


#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 16 May 2016 - 08:10 AM

Hi Radu,

 

Thank you very much for your input. The code you wrote is exactly what STV is doing behind the scenes, but for some strange reason it's not working on the last item of an SCArrayOfObjectsModel. If you've tested the above and it's working well, it's perfectly fine to ship like that.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users