ios - RestKit with CoreData and pagination -


i have simple pagination scheme

http://api/users?page=1

gives users @ page 1 after can ask next page like

http://api/users?page=2

and etc next pages

but have 2 problems:

  1. 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?

  1. 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?

  1. no, need add page number store , add sort descriptors page , index.
  2. 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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -