核心数据NSPredicate的关系

Mug*_*nth 10 iphone cocoa cocoa-touch osx-leopard core-data

我的对象图很简单.

我有一个feedentry对象,它存储有关RSS提要的信息和一个名为Tag的关系,该关系链接到"TagValues"对象.关系(to和inverse)都是to-many.即,馈送可以具有多个标签,并且标签可以与多个馈送相关联.

我提到了如何通过关系进行核心数据查询?并创建了一个NSFetchRequest.但是在获取数据时,我得到一个异常说明,

NSInvalidArgumentException谓词的未实现SQL生成

我该怎么办?我是核心数据的新手:(我知道我做了一件非常糟糕的事情......请帮忙......

谢谢

-

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"FeedEntry" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"authorname" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

[fetchRequest setSortDescriptors:sortDescriptors];

NSEntityDescription *tagEntity = [NSEntityDescription entityForName:@"TagValues" inManagedObjectContext:self.managedObjectContext];
NSPredicate *tagPredicate = [NSPredicate predicateWithFormat:@"tagName LIKE[c] 'nyt'"];          
NSFetchRequest *tagRequest = [[NSFetchRequest alloc] init];
[tagRequest setEntity:tagEntity];
[tagRequest setPredicate:tagPredicate];

NSError *error = nil;
NSArray* predicates = [self.managedObjectContext executeFetchRequest:tagRequest error:&error];


TagValues *tv = (TagValues*) [predicates objectAtIndex:0];
NSLog(tv.tagName); // it is nyt here...


NSPredicate *predicate = [NSPredicate predicateWithFormat:@"tag IN %@", predicates];
[fetchRequest setPredicate:predicate];


// Edit the section name key path and cache name if appropriate.
// nil for section name key path means "no sections".
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController; 
Run Code Online (Sandbox Code Playgroud)

-

res*_*ode 29

这里的关键是"任何"

苹果的例子:

NSPredicate *predicate = [NSPredicate predicateWithFormat:
    @"ANY employees.firstName like 'Matthew'"];
Run Code Online (Sandbox Code Playgroud)

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CoreData/Articles/cdBindings.html


emp*_*emp 3

你需要 SQLite 吗?我正在努力解决类似的问题,并且发现二进制存储一切都按预期工作。
使用 SQLite 作为存储时存在一些限制,尽管我还没有找到列出这些限制的文档,只是它们存在。

抱歉,我无法提供更多帮助。