- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有下面的方法可以取出一页 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
最佳答案
很难说出您在这里尝试做什么,但这可能是您的错误的来源。
if ([allMessages[i] text] == [messages[j] text]) {
这不是字符串比较,因此如果您使用它来比较字符串,将会产生不可预知的结果。 (由于内部优化,一些短字符串实际上会共享相同的内存地址,但大多数字符串将不相等,即使它们包含完全相同的文本)
您应该使用 isEqualToString:
来比较字符串。
if ([[allMessages[i] text] isEqualToString:[messages[j] text]]) {
-
然而,即使这可能不是您在调试测试中想要的,您不是要在这里比较实际的消息对象吗?在这种情况下,您可以使用直接对象比较。
if (allMessages[i] == messages[j]) {
关于ios - 在 CoreData 中设置 NSFetchRequest 的 fetchOffset 结果不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50447862/
我想使用 iOS10 中引入的新核心数据 API。 @available(iOS 10.0, *) open class func fetchRequest() -> NSFetchRequest 我
使用此函数对表格 View 中的单元格进行排序。我的获取请求中出现错误。 do 循环内的行 notes = try context.fetch(request) 导致错误,请求带有下划线 错误显示“无
我的核心数据模型中有一个名为 Task 的实体。 Task 实体有一个名为 date 的可转换属性。 date 属性的类是一个名为 TDate 的类(它符合 NSCoding,因此是一个可转换的属性)
使用 NSFetchedResultsController 和 NSFetchRequest 可以设置返回每个属性中最高值的查询。 例如: Entity_001 A=F B=27 C=57 Entit
我有两个实体:Patient 和 Job。患者与作业具有一对多关系,称为“作业”,而作业与患者具有一对一关系,称为“患者”。作业具有名为“dueDate”(日期)和“已完成”(BOOL)的属性,而患者
如果不提供 NSSortDescriptor,我们就无法使用 NSFetchRequest。我想要做的就是获取结果并按创建顺序显示它们。有没有内置的方法可以做到这一点?或者我必须创建一个新的“自动增量
我必须为我的 iPhone 应用程序创建一个 NSFetchRequest,它返回与以下 SQL 语句相同的结果: SELECT week , year , SUM(durat
我在 MacOsX 10.6 上使用 SQL 存储时遇到了 CoreData 的奇怪问题。我有一个NSManagedObject子类名为 Family具有属性 name和关系personList连接到
我的数据模型如下:类别 —>名字 —>items(“汽车”类型的项目数组) 我正在尝试获取部分作为名称,行应该是项目(这是一个 NSArray) 这是我的代码,我期望将行作为 Car 返回,但它仍然返
我有一个数据列表,其中父子层次结构最多为三个级别。例如 项目A(祖 parent ) 项目B1(父级) 项目C1(子级) 项目C2(子级) 项目C3(子级) 项目B2(父级) 项目C4(子级) ...
当从核心数据库获取数据并同时更新同一实体的数据时,fetchRequest 返回 nil let fetchRequest = NSFetchRequest(entityName: "Abc")
我有下面的方法,我通过 NSDate() 来获取今天的所有结果。我试图在午夜到午夜之前得到结果,但似乎不起作用。我注意到我的谓词输出如下: "date >= CAST(460249200.000000
我试图在 tableView 中显示项目,但我的 fetchResult 数组没有显示任何内容。我得到这个 NSLog: 2013-09-13 13:02:01.088 Prototype[67018
关于这个问题,我正在回答我自己的问题。在我看到尽可能多的其他答案之前,我不会接受它。 在过去的几天里,我一直在努力处理下面的代码 - (id)fetchUniqueEntity:(Class)enti
我有一个 Student 实体,它有一个 dateOfBirth 属性。 我想从 Student 实体中获取所有 Students,按出生日期的升序排列,但按月份的降序排列。 例如:属于同一月份的学生
我是 CoreData 的新手,正在尝试编写一个通用函数来查询数据库中的信息。我遇到了一些问题。 我设置了一个名为 NSError *error 的私有(private)变量。我的代码如下所示: @i
我正在使用自定义源表达式 NSExpression(format: "FETCH(FUNCTION($manager, \"customFetchRequestForSourceEntityNamed
我有一个 NSFetchRequest(在 NSFetchedResultsController 中执行)用于以下数据: Person (one-to-many) Encounter Encounte
我的程序有一个带有两个相关表的 sqlite 数据库。一个称为“排名”,另一个称为“要求” 我想从“Requirement”表中获取与“Rank”表中的特定行有关系的所有行。以下是我的代码,它获取整个
我已经就与此相关的不同事情发布了类似的问题,但已经为此苦苦挣扎了大约一周,但无济于事。这一切都归结为这段代码: NSFetchRequest *oldFetchRequest = [[NSFetchR
我是一名优秀的程序员,十分优秀!