早上好。
当我在我的设备上运行我的应用程序时遇到问题,当我在主 tableView 中滚动时它会滞后/卡顿。
我已将问题缩小到从 tableCell 内部调用核心数据
--在 indexPath 行的单元格中,人是一个自定义类,联系人管理器是我的文件,其中包含我对核心数据和操作数据的所有调用
person.contactSelected = [contactManager checkContactSelectedStatus:person];
-- 在我的contactManager 文件中,调用转到了这个函数。
并仅更新联系人选择状态(当用户按下按钮以更改通话中允许或不允许通话时)
-(NSNumber *) checkContactSelectedStatus:(ContactPerson *)person{
SWNAppDelegate *delegate = [[UIApplication sharedApplication]delegate];
NSManagedObjectContext *context = [delegate managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Contact" inManagedObjectContext:context];
NSFetchRequest *req =[[NSFetchRequest alloc]init];
[req setEntity:entity];
NSPredicate *pred =[NSPredicate predicateWithFormat:@"(recordID like %@)",[person.recordID stringValue]];
[req setPredicate:pred];
NSError *error;
NSManagedObject *checkStatus = [[context executeFetchRequest:req error:&error] objectAtIndex:0];
person.contactSelected = [checkStatus valueForKey:@"isSelected"];
return person.contactSelected;}
有没有一种简单的方法可以将它放入队列中?我已阅读并试图弄清楚如何将 NSManagedObject 发送到队列,但是当我创建父 MoC 的子代时,它找不到实体“联系人”。我不知道是否有更简单的方法来做到这一点!?
感谢您的宝贵时间,以及 WhatWasITthinking!?!?!