gpt4 book ai didi

iphone - 使用 NSPredicate 获取核心数据对象的问题

转载 作者:行者123 更新时间:2023-11-29 13:15:57 24 4
gpt4 key购买 nike

在开始之前,让我先介绍一下我的数据模型:

enter image description here

然后我有一个带有以下谓词的获取请求:

NSArray *allowedPackNames = @[@"success, happiness, free"];
self.fetchedResultsController = [Author MR_fetchAllGroupedBy:nil
withPredicate:[NSPredicate predicateWithFormat:@"ANY quotes.quote.pack.packName IN %@", allowedPackNames]
sortedBy:AuthorKeys.name
ascending:YES
delegate:self];

我想获取所有引用 packName 为成功、幸福或免费的作者。正如您在下面的关系表中所见,Author 有一个 NSSet of quotes。但是,当我执行此操作时,出现以下错误:

CoreData: error: (1) I/O error for database at /Users/Abdul/Library/Application Support/iPhone Simulator/6.1/Applications/DA17421B-A54D-42E3-9694-FDCBFF7F8BA4/Library/Application Support/MyCoolApp/MyCoolApp.sqlite.  SQLite error code:1, 'no such column: t2.ZQUOTE'
2013-04-05 15:26:47.175 MyCoolApp[78622:c07] Core Data: annotation: -executeRequest: encountered exception = I/O error for database at /Users/Aditya/Library/Application Support/iPhone Simulator/6.1/Applications/DA17421B-A54D-42E3-9694-FDCBFF7F8BA4/Library/Application Support/MyCoolApp/MyCoolApp.sqlite. SQLite error code:1, 'no such column: t2.ZQUOTE' with userInfo = {
NSFilePath = "/Users/Abdul/Library/Application Support/iPhone Simulator/6.1/Applications/DA17421B-A54D-42E3-9694-FDCBFF7F8BA4/Library/Application Support/MyCoolApp/MyCoolApp.sqlite";
NSSQLiteErrorDomain = 1;
}

知道为什么吗?

最佳答案

如果我没看错的话,谓词应该是

[NSPredicate predicateWithFormat:@"ANY quotes.pack.packName IN %@", allowedPackNames]

即您必须删除“quote”,它是 Quote 实体的属性,而不是关系。

关于iphone - 使用 NSPredicate 获取核心数据对象的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15829534/

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