Code Monkey home page Code Monkey logo

Comments (10)

3lvis avatar 3lvis commented on July 22, 2024

Hi Amanbolat,

Interesting problem. I believe the error is happening because new animations are starting while other ones are in progress. Combining multiple data sources in one table view has given me a lot of headaches in the past, I think we could figure out some workarounds if we manage to reproduce the error in a sample project, but have you considered using 3 table views each one with a different data source and just switch between them when the segmented control changes his value? Might make things much faster.

from datasource.

amanbolat avatar amanbolat commented on July 22, 2024

I will try your method with multiple table views and also will create sample project to reproduce the error.

from datasource.

amanbolat avatar amanbolat commented on July 22, 2024

@3lvis I found problem. Because i have only one tableView and multiple dataSources, each time i change dataSource for my tableView, previous dataSource doesn't stop call functions of it's NSFetchedResultsControllerDelegate functions:
controllerWillChangeContent
controllerDidChangeContent
If i'm right all these methods still use tableView and cause problem.
So i added new var isUpdatingTableView = true and this method, that i call when user changes segment of segmentedControl:

func segmentValueChanged(segmentedControl: UISegmentedControl) {
    if segmentedControl.selectedSegmentIndex == 0 {
      dataSourceONE.isUpdatingTableView = true
      dataSourceTWO.isUpdatingTableView = false
      dataSourceTHREE.isUpdatingTableView = false
      self.tableView.dataSource = dataSourceONE
      self.activeFRCSource = dataSourceONE

    } else if segmentedControl.selectedSegmentIndex == 1 {
      dataSourceTWO.isUpdatingTableView = true
      dataSourceONE.isUpdatingTableView = false
      dataSourceTHREE.isUpdatingTableView = false
      self.tableView.dataSource = dataSourceTWO
      self.activeFRCSource = dataSourceTWO

    } else if segmentedControl.selectedSegmentIndex == 2 {
      dataSourceTHREE.isUpdatingTableView = true
      dataSourceTWO.isUpdatingTableView = false
      dataSourceONE.isUpdatingTableView = false
      self.tableView.dataSource = dataSourceTHREE
      self.activeFRCSource = dataSourceTHREE
    }
    self.tableView.reloadData()
}

I think u can add feature it to your DATASource if somebody faced same problem.

from datasource.

3lvis avatar 3lvis commented on July 22, 2024

Hi @amanbolat,

Before I had something like what you're showing here, but it ended up introducing more problems than solutions. I'm happy that you got to fix your issue, I still think having multiple-controllers and datasources, or even just updating the predicate when switching datasources could be a better solution.

https://github.com/3lvis/DATASource/blob/master/Source/DATASource.swift#L84-L102

Let me know if I can help with anything else.

Best,

from datasource.

3lvis avatar 3lvis commented on July 22, 2024

Something like this could help too

http://stackoverflow.com/a/28878191/717416

from datasource.

amanbolat avatar amanbolat commented on July 22, 2024

Thanks, it's good idea. I'll try it too.

from datasource.

3lvis avatar 3lvis commented on July 22, 2024

@amanbolat Is there a chance you could share a sample project reproducing this issue? Would be nice to get it fixed in case is affecting other users too.

from datasource.

amanbolat avatar amanbolat commented on July 22, 2024

@3lvis https://github.com/amanbolat/DATASourceMultipleSourceSample
On viewDidLoad it will fetch data and save to core data, then u can delete and fetch again, until u delete go to another segment fetch again and go back to first segment.

But i don't use your DATAStack, because i'm not so good at Core Data and have my own stack.

EDIT: I added Delete button to reproduce issue, because in my app i use our company ERP API where data is edited, deleted, added every minute and user need to be synced.

from datasource.

3lvis avatar 3lvis commented on July 22, 2024

@amanbolat thanks a lot! This is very useful.

from datasource.

3lvis avatar 3lvis commented on July 22, 2024

Doing some spring cleaning, please make a new issue if you still want to do this.

from datasource.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.