-(NSError*)deleteObject:(NSManagedObject*)mo;
{
NSLog(@" Num objects in store before delete: %i ",
[[self.fetchedResultsController fetchedObjects] count]);
[self. managedObjectContext deleteObject:mo];
// Save the context.
NSError *error = nil;
if (![self.managedObjectContext save:&error]) {
}
// [self.fetchedResultsController performFetch:&error]; // force a fetch
NSLog(@" Num objects in store after delete (and save ): %i ",
[[self.fetchedResultsController fetchedObjects] count]);
return error;
}
(complete The NSObjectInaccessibleException is: “The application’NSObjectInaccessibleException’ was terminated due to an uncaught exception, reason:’CoreData could not resolve the error 0x1dcf90′
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { }
Thanks to BenT for his answer on the Apple Dev forum (see comments above). I asked him for the explanation of the fix, and he said: “The iPad is using iPhone OS 3.2 and the iPhone is using iPhone. In Some improvements were made to NSFetchedResultsController in 3.2, but unfortunately, this requirement for delegates actually has a side effect to implement a (any) delegate method to get proactive change tracking.” https://devforums.apple.com/ message/221471#221471(Hope this can help someone. The FAQ says that you can answer your own question in this case)
When the iPhone (ios 3.1 ) When the following code is run, the number of objects obtained after deletion is one less than before deletion. But on iPad (ios 3.2), the number is still the same. This inconsistency caused iPad to crash, because elsewhere in the code, shortly after deletion , The calling code that calls fetchedObjects and trust count tries to access the properties of the object that was just deleted, resulting in an NSObjectInaccessibleException error (see below). The fix has always been to use the commented out call to tryFetch, and when it is executed, fetchObjects is called a second time Will produce the same results as the iPhone without it. My question is: Why does the iPad produce different results from the iPhone? This is the second difference I recently discovered and published.
-(NSError*)deleteObject:(NSManagedObject*)mo;
{
NSLog(@" Num objects in store before delete: %i ",
[[self.fetchedResultsController fetchedObjects] count]);
[self. managedObjectContext deleteObject:mo];
// Save the context.
NSError *error = nil;
if (![self.managedObjectContext save:&error]) {
}
// [self.fetchedResultsController performFetch:&error]; // force a fetch
NSLog(@" Num objects in store after delete (and save ): %i ",
[[self.fetchedResultsController fetchedObjects] count]);
return error;
}
(complete The NSObjectInaccessibleException is: “The application’NSObjectInaccessibleException’ was terminated due to an uncaught exception, reason:’CoreData could not resolve the error 0x1dcf90′
Add the following code To FRC delegate will solve this problem.
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {}
Thanks to BenT for Apple Dev Answer on the forum (see comments above). I asked him for the explanation of the fix and he said : “IPad is using iPhone OS 3.2 and iPhone is using iPhone. Some improvements were made to NSFetchedResultsController in 3.2, but unfortunately, this requirement for delegates actually has a side effect to implement a (any) delegate method to obtain Proactive change tracking.” https://devforums.apple.com/message/221471#221471 (hope this helps someone. The FAQ says you can answer your own questions in this case)
p>