Giter Site home page Giter Site logo

Comments (10)

bigfish24 avatar bigfish24 commented on June 23, 2024

This won't be possible right now because Realm doesn't make available limiting through their query API (I believe the TightDB core offers this though they just haven't added it to the wrapper). So the only way would be to loop through the RLMResults and copy the first X into a NSArray for example. You can do this manually since it wouldn't make sense to setup RBQFetchrequest to work this way, because if you don't need a limit this isn't very performant. Makes sense?

from rbqfetchedresultscontroller.

bigfish24 avatar bigfish24 commented on June 23, 2024

FYI: here's relevant Realm issue regarding adding a limit to RLMResults (which RBQFetchRequest uses) realm/realm-swift#1448

from rbqfetchedresultscontroller.

 avatar commented on June 23, 2024

Thanks for your reply.I'll try other way to solve my problem, wish realm can update soon.

from rbqfetchedresultscontroller.

bigfish24 avatar bigfish24 commented on June 23, 2024

No problem, sorry couldn't be of more help. The one thing I should note is that at least in terms of memory management it isn't necessary to limit the results since RLMResults lazy loads the objects. So if you simply used the RLMResults directly as a UITableView datasource (instead of the FRC since internally it has its own cache complicating my point), then when the user scrolls and a cell is created, only then is the data accessed from the object at that specific index in the RLMResults. This prevents the need to limit the results or do any paging.

from rbqfetchedresultscontroller.

 avatar commented on June 23, 2024

Yeah, I limit the count just for paging logic.

from rbqfetchedresultscontroller.

bigfish24 avatar bigfish24 commented on June 23, 2024

Ah, well in that case if you are simply trying to achieve a UI effect, you don't need to actually page the RLMResults to improve performance. Just limit the rows on the UITableview manually (i.e. don't match the rows in UITableview datasource to the RLMResults count), and then increase this by X until you reach the results count in response to the user requesting to see more.

from rbqfetchedresultscontroller.

bigfish24 avatar bigfish24 commented on June 23, 2024

The only tricky thing with this would be if you plan to use RBQFetchedResultsController to manage changes to the UITableView, you would have to catch any delegate calls that reference a index path that is not currently visible and not pass that change to the UITableView or you will get an assertion failure.

from rbqfetchedresultscontroller.

 avatar commented on June 23, 2024

That's the problem so I tried other way: every model I have a flag and I reset all model's flag to false after refresh then set the new fetched model's flag to true then addOrUpdate.Througn this way i can limit the count.

from rbqfetchedresultscontroller.

bigfish24 avatar bigfish24 commented on June 23, 2024

Ah that makes sense, glad you figured out a fix for the time being.

from rbqfetchedresultscontroller.

andreaferrando avatar andreaferrando commented on June 23, 2024

Great thanks! I noticed this post is a bit old, are there any updates?

from rbqfetchedresultscontroller.

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.