相关疑难解决方法(0)

从coredata中检索数据,其中实体具有NSSet

我正在尝试使用谓词来获取我想要搜索的数据所在的数据 NSSet

@property (nonatomic, retain) NSSet *categories;
@property (nonatomic, retain) NSString *otherDetails;
@property (nonatomic, retain) NSNumber *id;
Run Code Online (Sandbox Code Playgroud)

NSSet类别是从另一个实体组成,包含:

@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSNumber *id;
Run Code Online (Sandbox Code Playgroud)

然后尝试通过谓词得到这个

NSFetchRequest *fetcher =[NSFetchRequest fetchRequestWithEntityName:@"MyEntity"];
fetcher.predicate = [NSPredicate predicateWithFormat:@categories in  %@", catList];
Run Code Online (Sandbox Code Playgroud)

其中catList是:

NSmutableArray *catList = [[NSMutableArray alloc] init];
Run Code Online (Sandbox Code Playgroud)

并填充数据

这就是给我以下错误

'NSInvalidArgumetException', reason: 'unimplemented SQL generation for predicate: (categories IN {"this", "that"});
Run Code Online (Sandbox Code Playgroud)

我尝试将其更改为使用这样的NSSet字段

fetcher.predicate = [NSPredicate predicateWithFormat:@categories.name in  %@", catList];
Run Code Online (Sandbox Code Playgroud)

但这没用.

如果我更改谓词使用NSString它不会出错,但由于数据不同,不会返回任何结果.

fetcher.predicate = [NSPredicate predicateWithFormat:@categories …
Run Code Online (Sandbox Code Playgroud)

sqlite core-data nsset ios

3
推荐指数
1
解决办法
3581
查看次数

CoreData - 使用NSSet进行NSPredicate

我有一个DB具有以下关系:

在此输入图像描述

A << - >> B

A:会员表; B:活动表

会员有很多活动,每个活动都有很多会员.所以,有多对多的关系.

当用户从tableView中选择一个Activity时,应该使用具有该Activity的所有成员推送一个新的tableView.

在"child"tableView的NSPredicate中,我这样做:

request.entity = [NSEntityDescription entityForName:@"Members" inManagedObjectContext:context];    
request.predicate = [NSPredicate predicateWithFormat:@"memberActivity = %@", [NSSet setWithObject:activity]];
Run Code Online (Sandbox Code Playgroud)

结果是:

***由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'此处不允许使用多对键'

我究竟做错了什么?

谢谢,

RL

many-to-many core-data objective-c nspredicate

2
推荐指数
1
解决办法
3395
查看次数

标签 统计

core-data ×2

ios ×1

many-to-many ×1

nspredicate ×1

nsset ×1

objective-c ×1

sqlite ×1