-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RBQFetchRequest add fetchLimit support. #5
Comments
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? |
FYI: here's relevant Realm issue regarding adding a limit to RLMResults (which RBQFetchRequest uses) realm/realm-swift#1448 |
Thanks for your reply.I'll try other way to solve my problem, wish realm can update soon. |
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. |
Yeah, I limit the count just for paging logic. |
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. |
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. |
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. |
Ah that makes sense, glad you figured out a fix for the time being. |
Great thanks! I noticed this post is a bit old, are there any updates? |
Sometimes may need limit fetched count like NSFetchRequest, can you add fetchlimit to RBQFetchRequest? Thanks.
The text was updated successfully, but these errors were encountered: