About coreData paging queries

30 views Asked by At
    NSMutableArray * temArray = [[NSMutableArray alloc]init];
    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
    NSPredicate *trackTableFilter;
    trackTableFilter = [NSPredicate predicateWithFormat:@"latest_status=%@", @"InTransit"];
  
    NSFetchRequest * request = [TrackTable MR_requestAllWithPredicate:trackTableFilter inContext: context];
    
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"isTopDate" ascending:YES];
   
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
    [request setSortDescriptors:sortDescriptors];
    [request setIncludesPendingChanges:YES];
    
    [request setFetchLimit:10];
    
    [request setFetchOffset:pageCount*10];
  //Problem in this part: if there are 15 data, the user pulls up the load to the second page, all the data in the database has been loaded, then add 1 data (that is, the 16th data), this is the user then use the function of pull up the load, can not be loaded out of the second data, because now pageCount is already the second page, it should be loaded from the 20th data. The pageCount is now on page 2, and should start loading from the 20th entry, but now there are only 16 entries in the database, so the 16th entry cannot be loaded. I don't know how to solve it. Please help me. Thank you very much. .

    NSArray * arrayss = [TrackTable MR_executeFetchRequest:request];

`

I want to try to use something like select id >XX limit 10, but CoreData doesn't know how to implement it.

0

There are 0 answers