【发布时间】:2017-09-16 19:22:00
【问题描述】:
我有一个核心数据表,它包含 100 个数据和一个可变数组有一些数据。 iw ant 搜索包含数据的可变数组是否存在于表中。可变数组包含 3 个使用这些参数的参数我需要找出一个包含我表的 id 我正在使用此代码
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ IN self.@allKeys" ,self.beaconListArray ];
request.predicate = predicate;
NSError *error = nil;
NSArray *objs = [managedObjectContext executeFetchRequest:request error:&error];
if (error) {
[NSException raise:@"no find" format:@"%@", [error localizedDescription]];
NSLog(@"there is noooo with same id exsist");
}
if (objs.count > 0) {
NSLog(@"there is a with same id exsist. Use update method");
}else {
NSLog(@"there's no with same id. Use insert method");
}
【问题讨论】:
标签: ios objective-c xcode core-data nspredicate