gpt4 book ai didi

ios - +entityForName : nil happens intermittently

转载 作者:行者123 更新时间:2023-11-29 00:21:19 26 4
gpt4 key购买 nike

我有一个使用核心数据的项目,这个错误会间歇性地发生。我知道实体在那里,因为大多数时候,应用程序打开并显示 entityName 的内容。1. 这是在应用程序委托(delegate)中发生的,而不是被 segue'd2. 当我执行 [self.managedObjectModel entities] 时,entityName 在那里但应用程序崩溃3.不拼错。4.它发生在同一个地方,同一个时间(应用程序启动)

NSManagedObjectContext *contOBJ = self.managedObjectContext;
NSEntityDescription *entity;
NSString * entityForNameString = @"MessageLists";
@try {
entity = [NSEntityDescription entityForName:entityForNameString
inManagedObjectContext:contOBJ];
}
@catch (NSException* exception) {
NSLog(@"DANGER DANGER - ERROR FOUND");
NSLog(@"Uncaught exception: %@", exception.description);

// ditch effort to reset manageObject BUT DOES NOT WORK...
[self.managedObjectContext reset];
// ditch effort to reset manageObject BUT DOES NOT WORK...

return nil;
NSLog(@"Stack trace: %@", [exception callStackSymbols]);

// Reset the store
}
@finally {
NSLog(@"finally");
}
NSFetchRequest *fetcher = [[NSFetchRequest alloc] init];
// need to define a predicate that will institute weather a message thread is deleted or NOT
[fetcher setEntity:entity];
NSError *error;
NSLog(@"All Records is %@",[contOBJ executeFetchRequest:fetcher error:&error]);
return [contOBJ executeFetchRequest:fetcher error:&error];

最佳答案

不要使用那些旧的字符串类型的东西,就这样做

NSFetchRequest *fetchRequest = [MessageLists fetchRequest];
NSError *error;
NSLog(@"All Records is %@",[context executeFetchRequest:fetchRequest error:&error]);

关于ios - +entityForName : nil happens intermittently,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44171988/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com