I have a OUP
record type, and it has a .DeleteSelf
reference to a OU
record type.
If I just set up an unconditional subscription, that works:
let subscriptionOUP = CKSubscription(recordType: "OUP", predicate:NSPredicate(value: true), subscriptionID: "oup", options: .FiresOnRecordUpdate)
But the conditional way not:
let ekf = "oup-\(ou.recordID)"
let pr = NSPredicate(format: "ou = %@", CKReference(recordID: CKRecordID(recordName: organizationUser.recordID), action: .DeleteSelf))
let subscriptionOUP = CKSubscription(recordType: "OUP", predicate:pr, subscriptionID: ekf, options: .FiresOnRecordUpdate)
println("\(pr) \(ekf)")
Terminal content:
ou == <CKReference: 0x1558d3d0;51D56239-D68C-4E12-BD23-E4DCEF5721B7:(_defaultZone:__defaultOwner__)>
oup-51D56239-D68C-4E12-BD23-E4DCEF5721B7
What is the problem with my predicate or subscriptionID?
The subscriptionID
string is too long.
When you reduce it like this, it will work:
let ekf = "oup-\((organizationUser.recordID as NSString).substringToIndex(7))"