I am storing some data in data. when i click on button the data in the coredata will be delete. I am using the below code.
我在数据中存储了一些数据。当我点击按钮时,coredata中的数据将被删除。我使用以下代码。
NSManagedObjectContext *context = [[YPOAppDelegate sharedAppDelegate] managedObjectContext];
NSManagedObjectModel *model = [[YPOAppDelegate sharedAppDelegate] managedObjectModel];
for (NSEntityDescription *entity in model) {
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
[fetchRequest setIncludesSubentities:NO];
NSArray *objects = [context executeFetchRequest:fetchRequest error:nil];
NSLog(@"objects ===%d",objects.count);
for (NSManagedObject *managedObject in objects)
{
[context deleteObject:managedObject];
}
}
NSError *err;
[context save:&err];
It's getting an error and app is crashed that is Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x7e3937f0
由于未捕获的异常'NSObjectInaccessibleException'导致应用程序崩溃,即终止应用程序,原因是:'CoreData无法解决'0x7e3937f0的错误
How to fix this crash issue. Please give me your suggestions.
如何解决此崩溃问题。请给我你的建议。
1 个解决方案
#1
0
Before deleting please weather you have that particular object or not ?
在删除之前请天气你有特定的对象吗?
if ([ListObjetcts existingObjectWithID:objects.objectID error:&error])
{
}
#1
0
Before deleting please weather you have that particular object or not ?
在删除之前请天气你有特定的对象吗?
if ([ListObjetcts existingObjectWithID:objects.objectID error:&error])
{
}