我遇到了我的Iphone应用程序的另一个问题,我无法自行解决。 我在我的最新应用程序中实现了一种管理器功能。 可以创建约会,这些约会显示在tableview中并保存在CoreDataStore中。我使用4个类:
代码:
-(void)createAppointmentObjectWithDate:(NSDate *)
appointmentDate name:(NSString *)appointmentName
description:(NSString *)appointmentDescription
eDate:(NSDate *)appointmentEndDate
{
NSManagedObjectContext *managedObjectContext = [[CoreDataManager sharedManager] managedObjectContext];
AppointmentObject *newAppointmentObject = [NSEntityDescription insertNewObjectForEntityForName:AppointmentObjectEntityName
inManagedObjectContext:managedObjectContext];
newAppointmentObject.appointmentName = appointmentName;
newAppointmentObject.appointmentDescription = appointmentDescription;
newAppointmentObject.appointmentDate = [appointmentDate earlierDate:appointmentEndDate];
newAppointmentObject.appointmentEndDate = [appointmentEndDate laterDate:appointmentDate];
}
-(void)deleteAppointmentObject:(AppointmentObject *)appointmentObject triggeredByUser:(BOOL)byUser{
NSManagedObjectContext *managedObjectContext = [[CoreDataManager sharedManager] managedObjectContext];
[managedObjectContext deleteObject:appointmentObject];
}
但是发生了各种疯狂的事情,这让我的应用程序崩溃了“SICBART”消息:
2010-10-13 17:35:04.630 didacta[109:307] Serious application error. Exception was caught during Core Data change processing.
This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.
-[CALayer controllerWillChangeContent:]: unrecognized selector sent to instance 0x19f150 with userInfo (null)
2010-10-13 17:35:05.118 didacta[109:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer controllerWillChangeContent:]: unrecognized selector sent to instance 0x19f150'
执行此操作时出现错误:
有时候我甚至可以删除一个约会,但是那个tableview中项目的顺序不知何故被扭曲了,所以tableview的索引不再指向约会的索引了。
答案 0 :(得分:3)
右。
- [CALayer controllerWillChangeContent:]:使用userInfo(null)发送到实例0x19f150的无法识别的选择器
那是你的错误。您有一个NSFetchedResultsController,其委托是CALayer。这听起来像原始委托被解除分配,并且使用相同的内存区域分配了CALayer。修复方法是找到有问题的-dealloc
并添加类似self.myFetchedResultsController.delegate = nil; self.myFetchedResultsController = nil;
的内容,假设您正在使用属性。
你有时可以通过启用僵尸来帮助调试这样的事情(转到Project→Edit Current Executable左右,选择Environment,添加NSZombieEnabled环境变量,并将其值设置为“YES”左右;取消选中该复选框已完成调试。当消息发送到解除分配的对象时,僵尸会导致异常。 (默认情况下,僵尸不会被解除分配,因此您的应用程序将有效泄漏;请记得取消选中该复选框!)。
答案 1 :(得分:-2)
“无法识别的选择器”听起来好像您的数据模型可能不包含您尝试使用的某些实体属性。例如,您可能正在尝试设置不存在的对象的属性。
尝试在newAppointmentObject.appointmentName = appointmentName;
处创建一个断点,然后逐步查看该错误发生的位置。