ios - RestKit with CoreData and pagination -
i have simple pagination scheme
gives users @ page 1 after can ask next page like
and etc next pages
but have 2 problems:
- i can't ordering users in response show them came server me
[user1, user2, user3] when try fetch database can got [user2, user1, user3] example.
i try use restkit metadata property
@metadata.mapping.collectionindex
but it's work each request independently. happen next
http://api/users?page=1 got array
[user1, user2, user3] collectionindex [1,2,3].
but ask next page , got array
[user4, user5, user6] collectionindex [1,2,3]
so in database
[user1, user4, user2, user5, user3, user6]
it's not correct.
so first question: possible use collectionindex pagination requests without resets collectionindex?
- problem in new arrived data
i ask
http://api/users?page=1 , got 2 users
[user1, user2] in response
after ask second page , got 2 users
[user3, user4] in response
so ask again page=1 , got users [user01, user02]
and go increment page index but, in page=2 got [user1, user2] , in tableview in ui see al records
[user01, user02, user1, user2, user3, user4]
and page ask nothing changes, user can't understand paging work?
to fix use fetchrequestblock , page=1 erase users - it's bad solution.
how correct paginate data server?
- no, need add page number store , add sort descriptors page , index.
- i'd solution ok. i'm not sure i'd use fetch request block, need mark items invalid or delete them when start paging beginning.
Comments
Post a Comment