1

在开始之前,让我告诉你我的数据模型是什么样子的:

在此处输入图像描述

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

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 的引文的作者。正如您在下面的关系表中看到的,作者有一个 NSSet 引号。但是,当我执行此操作时,出现以下错误:

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;
}

知道为什么吗?

4

1 回答 1

1

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

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

即您必须删除“报价”,这是报价实体的属性,而不是关系。

于 2013-04-05T08:51:38.727 回答