views:

46

answers:

2

Hey Guys,

I am running into another problem with my Iphone App which I just can't solve myself. I implemented a kind of organizer functionality in my latest app. There one can create appointments which are displayed in a tableview and persisted in a CoreDataStore. I use 4 classes:

  • an overview where appointments are displayed
  • a view with textfields to put in Values for place and name of appointment (create/edit view)
  • a view with DatePicker to define start- and enddate
  • a controller which handles creation and deletion of items using this methods:

The code:

-(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];
}

But all kind of crazy stuff is happening which makes my app crash with "SICBART" message:

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'

errors appear while doing this:

  • creating new Appointment and pressing "Done" (should trigger creation and pop overview)
  • changing appointments and pressing "Done" (should send changes and pop overview)
  • tapping on an appointment in overview ( should pop create/edit view and hand over values)
  • deleting an item

sometimes I can even delete an appointment but then the order of the items in the tableview is somehow gotten twisted so the index of the tableview isn't pointing to the index of the appointment anymore.

I know this may all sound a lil weird but I am awake for about 36 hours right now trying to fix this problem and just can't find the solution. Any ideas where to look?

A: 

"unrecognized selector" makes it sound like maybe your data model doesn't contain some of the Entity attributes that you're trying to use. For example, maybe you're trying to set an attribute of the object that doesn't exist.

Try creating a breakpoint at newAppointmentObject.appointmentName = appointmentName; and step through it to see at what point the error occurs.

Nimrod
+1  A: 
tc.
I searched the code again, but there is no place where I deallocate the delegate. But now I finally I can reproduce an error: My appointments are sorted by date. When I change the date of an Item, the Tableview stops refreshing for some reason. But the order of the Items I get by the fetchedResultscontroller still is correct (with the item with changed date at right place). I update the Tableview by "reloaddata" at viewWillAppear. Could this be a trace?
Amandir
To be more precise: the CellForRow isn't called anymore. Not by delegate and not by reloadData. when I close the App and start it again. the appointments are in right order and the update of the tableView is working again.
Amandir
He means you have either deallocated the fetched results controller's delegate or you have assigned the CALayer as the delegate. When you make a change to the data, the CALayer receives the delegate error. If the error is consistent, you have assigned a CALayer as the delegate somewhere in the code.
TechZen