在CoreData中设置NSFetchRequest的fetchOffset结果不一致

问题描述 投票:0回答:1

我有下面的方法可以获取 CoreData 实体的页面。 当我传入

start
的值时,我得到的结果不一致。 有时它会按照我的预期进行分页,有时却确实不会。 它似乎从靠近我请求的地方得到结果,但经常与其他结果交织或跳过一些结果。

我通过每当请求特定页面时记录所有结果并将结果页面与整个列表进行比较来证明了这一点。 下面是调试日志

对于如何/为什么会发生这种情况有什么想法吗?

+(NSArray *)fetchMessagesForUser:(int32_t)userId connectionUserId:(int32_t)connectionUserId sortASC:(BOOL)sortASC startAt:(int)start size:(int)size sinceMessage:(ChatMessage*)since
{
    NSManagedObjectContext *context = [RKManagedObjectStore defaultStore].mainQueueManagedObjectContext;
    NSFetchRequest *fetchRequest = [ChatMessage fetchRequest];
    NSString *query = @"";
    query = [NSString stringWithFormat:@"(receiverId == %1$d && senderId == %2$d ) || (receiverId == %2$d  && senderId == %1$d) ",userId, connectionUserId];

    NSPredicate *predicate = [NSPredicate predicateWithFormat:query];
    fetchRequest.predicate = predicate;

    NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"dateSent" ascending:sortASC];
    [fetchRequest setSortDescriptors:@[sort]];

    if (size > 0) {
      fetchRequest.fetchLimit = size;
    }
    if (start > 0) {
      fetchRequest.fetchOffset = start;
    }
    NSError *error = nil;
    NSArray *messages = [context executeFetchRequest:fetchRequest error:&error];

    if (start > 0) {
      fetchRequest.fetchLimit = 0;
      fetchRequest.fetchOffset = 0;
      NSArray *allMessages = [context executeFetchRequest:fetchRequest error:&error];
      for (int i = 0; i < allMessages.count; i++) {
         bool inPaged = NO;
         for (int j = 0; j < messages.count; j++) {
            if ([allMessages[i] text] == [messages[j] text]) {
               inPaged = YES;
            }
         }
         NSLog(@"DEBUG fetchOffset: %@: %d", inPaged ? @"SAME" : @"DIFF", [allMessages[i] id]);
      }
      NSLog(@"DEBUG fetchOffset: Finished iterating and comparing the paged vs full result set");
    }

    //Remove non-unique messages (uniqueness determined by ID)
    NSMutableArray* originalMessages = [NSMutableArray arrayWithArray:messages];
    NSMutableArray* filteredMessages = [NSMutableArray array];
    for (int i = 0; i < [originalMessages count]; i++) {
        for (int j = 0; j < [originalMessages count]; j++) {
            if (i != j && [[originalMessages objectAtIndex:i] text] == [[originalMessages objectAtIndex:j] text]) {
                [context deleteObject:[originalMessages objectAtIndex:j]];
                [originalMessages removeObject:[originalMessages objectAtIndex:j]];
            }
        }
        [filteredMessages addObject:[originalMessages objectAtIndex:i]];
    }
    return filteredMessages;
}

所以运行这个会产生:

2018-05-21 12:15:40.800686+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22506
2018-05-21 12:15:40.800860+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22505
2018-05-21 12:15:40.801002+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22500
2018-05-21 12:15:40.801168+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22499
2018-05-21 12:15:40.801335+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22498
2018-05-21 12:15:40.801473+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22497
2018-05-21 12:15:40.801606+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22496
2018-05-21 12:15:40.801756+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22495
2018-05-21 12:15:40.801852+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22494
2018-05-21 12:15:40.801965+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22491
2018-05-21 12:15:40.802108+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22490
2018-05-21 12:15:40.802228+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22489
2018-05-21 12:15:40.802370+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22488
2018-05-21 12:15:40.802583+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22487
2018-05-21 12:15:40.802838+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22486
2018-05-21 12:15:40.803034+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22485
2018-05-21 12:15:40.803251+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22484
2018-05-21 12:15:40.803479+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22483
2018-05-21 12:15:40.803723+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22478
2018-05-21 12:15:40.803946+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 SAME: 22477
2018-05-21 12:15:40.804228+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22476
2018-05-21 12:15:40.804399+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22475
2018-05-21 12:15:40.804631+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22474
2018-05-21 12:15:40.804849+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22473
2018-05-21 12:15:40.805158+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22472
2018-05-21 12:15:40.805362+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22469
2018-05-21 12:15:40.805585+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22464
2018-05-21 12:15:40.805766+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22463
2018-05-21 12:15:40.805984+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22462
2018-05-21 12:15:40.806185+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22461
2018-05-21 12:15:40.806385+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22460
2018-05-21 12:15:40.806595+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22459
2018-05-21 12:15:40.806843+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22458
2018-05-21 12:15:40.807031+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22457
2018-05-21 12:15:40.807265+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22456
2018-05-21 12:15:40.807453+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22455
2018-05-21 12:15:40.807649+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22454
2018-05-21 12:15:40.807862+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22453
2018-05-21 12:15:40.808007+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22450
2018-05-21 12:15:40.808216+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22449
2018-05-21 12:15:40.808430+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22445
2018-05-21 12:15:40.808607+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22444
2018-05-21 12:15:40.808775+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22441
2018-05-21 12:15:40.808897+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22438
2018-05-21 12:15:40.809049+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22437
2018-05-21 12:15:40.809209+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22434
2018-05-21 12:15:40.809352+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22433
2018-05-21 12:15:40.809507+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22432
2018-05-21 12:15:40.809688+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22429
2018-05-21 12:15:40.809848+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22428
2018-05-21 12:15:40.814283+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22427
2018-05-21 12:15:40.814416+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22426
2018-05-21 12:15:40.814593+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22425
2018-05-21 12:15:40.814727+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22424
2018-05-21 12:15:40.814849+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22423
2018-05-21 12:15:40.815018+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22421
2018-05-21 12:15:40.815161+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22417
2018-05-21 12:15:40.815276+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22416
2018-05-21 12:15:40.815384+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22415
2018-05-21 12:15:40.815492+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22414
2018-05-21 12:15:40.815617+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22413
2018-05-21 12:15:40.815749+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22412
2018-05-21 12:15:40.815872+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22411
2018-05-21 12:15:40.815965+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22410
2018-05-21 12:15:40.816085+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22409
2018-05-21 12:15:40.816180+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22408
2018-05-21 12:15:40.816302+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22407
2018-05-21 12:15:40.817152+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 10 DIFF: 22406
2018-05-21 12:15:40.817326+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: Finished iterating and comparing the paged vs full result set
2018-05-21 12:16:54.251517+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22506
2018-05-21 12:16:54.251660+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22505
2018-05-21 12:16:54.251820+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22500
2018-05-21 12:16:54.251937+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22499
2018-05-21 12:16:54.252047+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22498
2018-05-21 12:16:54.252166+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22497
2018-05-21 12:16:54.252284+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22496
2018-05-21 12:16:54.252408+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22495
2018-05-21 12:16:54.252526+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22494
2018-05-21 12:16:54.252609+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22491
2018-05-21 12:16:54.252754+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22490
2018-05-21 12:16:54.252885+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22489
2018-05-21 12:16:54.252988+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22488
2018-05-21 12:16:54.253109+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22487
2018-05-21 12:16:54.253230+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22486
2018-05-21 12:16:54.253378+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22485
2018-05-21 12:16:54.253634+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22484
2018-05-21 12:16:54.253874+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22483
2018-05-21 12:16:54.254051+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22478
2018-05-21 12:16:54.254318+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 SAME: 22477
2018-05-21 12:16:54.254489+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22476
2018-05-21 12:16:54.254741+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22475
2018-05-21 12:16:54.254923+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22474
2018-05-21 12:16:54.255103+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22473
2018-05-21 12:16:54.255327+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22472
2018-05-21 12:16:54.255549+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22469
2018-05-21 12:16:54.255712+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22464
2018-05-21 12:16:54.255868+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22463
2018-05-21 12:16:54.256065+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22462
2018-05-21 12:16:54.256349+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22461
2018-05-21 12:16:54.256567+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22460
2018-05-21 12:16:54.256784+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22459
2018-05-21 12:16:54.257163+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22458
2018-05-21 12:16:54.257400+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22457
2018-05-21 12:16:54.257617+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22456
2018-05-21 12:16:54.257823+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22455
2018-05-21 12:16:54.258047+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22454
2018-05-21 12:16:54.258252+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22453
2018-05-21 12:16:54.258495+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22450
2018-05-21 12:16:54.258760+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22449
2018-05-21 12:16:54.259016+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22445
2018-05-21 12:16:54.259250+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22444
2018-05-21 12:16:54.259426+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22441
2018-05-21 12:16:54.259666+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22438
2018-05-21 12:16:54.259869+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22437
2018-05-21 12:16:54.260084+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22434
2018-05-21 12:16:54.260284+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22433
2018-05-21 12:16:54.260463+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22432
2018-05-21 12:16:54.260689+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22429
2018-05-21 12:16:54.260869+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22428
2018-05-21 12:16:54.261060+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22427
2018-05-21 12:16:54.261249+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22426
2018-05-21 12:16:54.261393+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22425
2018-05-21 12:16:54.261519+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22424
2018-05-21 12:16:54.261726+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22423
2018-05-21 12:16:54.261895+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22421
2018-05-21 12:16:54.262061+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22417
2018-05-21 12:16:54.266362+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22416
2018-05-21 12:16:54.266543+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22415
2018-05-21 12:16:54.266730+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22414
2018-05-21 12:16:54.266901+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22413
2018-05-21 12:16:54.267026+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22412
2018-05-21 12:16:54.267106+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22411
2018-05-21 12:16:54.267186+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22410
2018-05-21 12:16:54.267290+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22409
2018-05-21 12:16:54.267474+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22408
2018-05-21 12:16:54.267586+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22407
2018-05-21 12:16:54.267702+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 19 DIFF: 22406
2018-05-21 12:16:54.267809+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: Finished iterating and comparing the paged vs full result set
2018-05-21 12:19:17.342345+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22506
2018-05-21 12:19:17.342518+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22505
2018-05-21 12:19:17.342665+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22500
2018-05-21 12:19:17.342818+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22499
2018-05-21 12:19:17.342937+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22498
2018-05-21 12:19:17.343049+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22497
2018-05-21 12:19:17.343142+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22496
2018-05-21 12:19:17.343269+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22495
2018-05-21 12:19:17.343406+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22494
2018-05-21 12:19:17.343713+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22491
2018-05-21 12:19:17.344044+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22490
2018-05-21 12:19:17.344176+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22489
2018-05-21 12:19:17.344372+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22488
2018-05-21 12:19:17.344696+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22487
2018-05-21 12:19:17.344853+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22486
2018-05-21 12:19:17.345044+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22485
2018-05-21 12:19:17.345220+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22484
2018-05-21 12:19:17.345566+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22483
2018-05-21 12:19:17.345811+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22478
2018-05-21 12:19:17.346076+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22477
2018-05-21 12:19:17.346296+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22476
2018-05-21 12:19:17.346558+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22475
2018-05-21 12:19:17.346758+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22474
2018-05-21 12:19:17.347009+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22473
2018-05-21 12:19:17.347284+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22472
2018-05-21 12:19:17.347519+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22469
2018-05-21 12:19:17.347769+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22464
2018-05-21 12:19:17.348020+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22463
2018-05-21 12:19:17.348312+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22462
2018-05-21 12:19:17.348582+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 SAME: 22461
2018-05-21 12:19:17.348887+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22460
2018-05-21 12:19:17.349143+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22459
2018-05-21 12:19:17.349351+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22458
2018-05-21 12:19:17.349544+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22457
2018-05-21 12:19:17.349903+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22456
2018-05-21 12:19:17.350105+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22455
2018-05-21 12:19:17.350390+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22454
2018-05-21 12:19:17.350681+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22453
2018-05-21 12:19:17.350914+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22450
2018-05-21 12:19:17.351102+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22449
2018-05-21 12:19:17.351314+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22445
2018-05-21 12:19:17.351539+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22444
2018-05-21 12:19:17.351829+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22441
2018-05-21 12:19:17.352039+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22438
2018-05-21 12:19:17.352298+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22437
2018-05-21 12:19:17.352536+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22434
2018-05-21 12:19:17.352891+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22433
2018-05-21 12:19:17.353091+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22432
2018-05-21 12:19:17.353326+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22429
2018-05-21 12:19:17.353538+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22428
2018-05-21 12:19:17.353866+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22427
2018-05-21 12:19:17.354123+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22426
2018-05-21 12:19:17.354437+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22425
2018-05-21 12:19:17.354662+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22424
2018-05-21 12:19:17.354830+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22423
2018-05-21 12:19:17.355050+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22421
2018-05-21 12:19:17.355259+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22417
2018-05-21 12:19:17.355454+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22416
2018-05-21 12:19:17.355644+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22415
2018-05-21 12:19:17.355881+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22414
2018-05-21 12:19:17.356109+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22413
2018-05-21 12:19:17.356387+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22412
2018-05-21 12:19:17.356555+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22411
2018-05-21 12:19:17.356742+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22410
2018-05-21 12:19:17.356931+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22409
2018-05-21 12:19:17.357140+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22408
2018-05-21 12:19:17.357365+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22407
2018-05-21 12:19:17.357543+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: 20 DIFF: 22406
2018-05-21 12:19:17.357734+0100 Link-ages Hub[68958:9889355] DEBUG fetchOffset: Finished iterating and comparing the paged vs full result set
ios core-data pagination restkit
1个回答
4
投票

很难说出你想在这里做什么,但这可能是你的错误的根源。

if ([allMessages[i] text] == [messages[j] text]) {

这不是字符串比较,因此如果您使用它来比较字符串,将会产生不可预测的结果。 (由于内部优化,一些短字符串实际上会共享相同的内存地址,但大多数字符串即使包含完全相同的文本也不会相等)

您应该使用

isEqualToString:
来比较字符串。

if ([[allMessages[i] text] isEqualToString:[messages[j] text]]) {

-

但是,即使这可能不是您在调试测试中想要的,您是否尝试在此处比较实际的消息对象?在这种情况下,您可以使用直接对象比较。

if (allMessages[i]  == messages[j]) {

© www.soinside.com 2019 - 2024. All rights reserved.