gpt4 book ai didi

ios - NSBatchUpdateRequest 抛出 NSInternalInconsistencyException

转载 作者:行者123 更新时间:2023-11-29 11:46:52 28 4
gpt4 key购买 nike

我在尝试执行 NSBatchUpdateRequest 时不断收到以下错误。

*** Terminating app due to uncaught exception 

'NSInternalInconsistencyException', reason: 'Unknown command type

<NSBatchUpdateRequest : entity = Person, properties = {
"(<NSAttributeDescription: 0x6000000ff980>), name title, isOptional 1, isTransient 0, entity (null), renamingIdentifier title, validation predicates (\n), warnings (\n), versionHashModifier (null)\n userInfo {\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)" = "\"sometitle\"";
}, subentities = 1'

当在构造函数中正确指定时,错误日志显示“entity (null)”。

我正在运行这是一个测试环境,想知道 NSBatchUpdateRequest 是否支持带有 NSInMemoryStoreType 的 NSPersistentStoreCoordinator。我在文档中找不到任何说它不受支持的内容。

下面是我使用的代码。实体和属性参数正确,不应引起问题。

-(BOOL) updatePersonNamesFrom:(NSString*)oldName newName:(NSString*)newName {

NSBatchUpdateRequest* updateRequest = [[NSBatchUpdateRequest alloc] initWithEntityName:@"Person"]; // The person model definitely exists

NSLog(@"entity name: %@", updateRequest.entityName); // This logs the correct entity name

// Adding or removing a predicate has no effect
// [updateRequest setPredicate:[NSPredicate predicateWithFormat:@"name = %@", oldName];

updateRequest.propertiesToUpdate = @{@"name" : newName}; // Name field definitely exists on Person

NSError* error = nil;

[m_context executeRequest:updateRequest error:&error];

// Also tried this
// [m_context.persistentStoreCoordinator executeRequest:updateRequest withContext:self error:&error];

return error != nil;
}

如果有人有任何想法,我很想听听。

最佳答案

来自guide :

Important: Batch updates are only available when you are using a SQLite persistent store.

对不起。也许它会在 iOS 11 中工作。¯\_(ツ)_/¯

关于ios - NSBatchUpdateRequest 抛出 NSInternalInconsistencyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43269081/

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