gpt4 book ai didi

ios - 具有复杂谓词的 CKSubscription

转载 作者:行者123 更新时间:2023-12-01 16:39:39 25 4
gpt4 key购买 nike

我正在尝试使用 CKSubscription这边走:

NSArray *events = @[@1,@2,@3];
NSInteger myValue = 100;

NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(value > %@) AND (prev_value < %@) AND (event_type IN %@)",
@(myValue), @(myValue), events];

CKSubscription *sub = [[CKSubscription alloc] initWithRecordType:@"TableName"
predicate:predicate options:(CKSubscriptionOptionsFiresOnRecordCreation)];

[db saveSubscription:sub completionHandler:^(CKSubscription *s, NSError *error) {
if (error) {
NSLog(@"Error: %@", error.localizedDescription);
return;
}
NSLog(@"Success!");
}];

这让我出错:
Error: Error saving record subscription with id 781FB482-C9C9-4DA5-8022-CFDB8006223A to server:
invalid attempt to set value type NUMBER_INT64 for field 'binding_0' for type
'_sub_trigger_sub_220b17724b5262b0590a3c9d66be9826', defined to be: INT64_LIST

这看起来像是有效的 NSPredicate不能作为 CKSubscription 的一部分正确存储在 CloudKit 中目的。是真正的苹果虫还是我的?

附言通过删除谓词条件的不同部分,我尝试了很多不同的组合。看起来是 event_type 的唯一条件工作正常,但是当我将 3 个条件与 AND 混合时- 这会导致问题。

附言我正在使用 Xcode 6 beta 6OSX 10.10 DP6iOS8 beta 5在 iPhone 5S 上

更新:

具有以下谓词之一的订阅可以正常工作:
NSPredicate *predicate1 = [NSPredicate predicateWithFormat:
@"(value > %@) AND (prev_value < %@)", @(myValue), @(myValue)];

NSPredicate *predicate2 = [NSPredicate predicateWithFormat:
@"(event_type IN %@)", events];

但是使用公共(public)谓词保存订阅失败:
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(value > %@) AND (prev_value < %@) AND (event_type IN %@)",
@(myValue), @(myValue), events];

看起来像真正的 Apple CloudKit 错误。刚刚在 bugreport.apple.com 上打开问题 #18105879

更新 2:

感谢@purrrminator - 这里有两个雷达接收 CloudKit 推送通知有问题:

http://openradar.appspot.com/18807663

http://openradar.appspot.com/18798061

我找到了保存 CKSubscription 的解决方法正确地通过展示 IN有很多平等比较器的条件。但实际上我没有收到来自 CLoudKit 的推送通知......

最佳答案

尝试创建一个 CKNotification 对象,在将订阅添加到数据库之前将其添加到订阅中。还要确保检查与远程通知相关的所有委托(delegate)方法,包括 didFailToRegisterForRemoteNotificationsWithError。关于谓词问题,我建议尝试 NSCompoundPredicate并对 Predicates Programming Guide 进行更深入的审查其他选项。

关于ios - 具有复杂谓词的 CKSubscription,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25443133/

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