Why do CoreData ForceFetch instead of iPhone after deleting it on an iPad?

When running the following code on iPhone (ios 3.1), 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 the iPad to crash because elsewhere in the code, shortly after the deletion, the calling code that called fetchedObjects and trusted count tried to access the properties of the object that was just deleted, resulting in an NSObjectInaccessibleException error (see below). The fix has been correct. The commented out call of tryFetch, when executed, the second call to fetchObjects will produce the same result 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′

Adding the following code to the FRC delegate will solve this problem.

- (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)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 999 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.