I see in CKError.h there is an error: CKErrorConstraintViolation.
Is there a way to specify a unique constraint for a column in a CloudKit record?
The only part of a CloudKit record that enforces uniqueness as far as I can is recordName (which is specified via CKRecordID). This has limitations though. One being recordName must be 255 characters or less. For the most part, using user input on some field which must be unique in a user created record can be used as a record name to ensure uniqueness. In most cases, this will be under 255 characters but not always though.
During testing, I'm just using a hash string for the record name, which will fit in 255 characters:
NSString *someStringThatRepresentsUniqueValue = //...
NSString *ckRecordName = [NSString stringWithFormat:@"%lu",someStringThatRepresentsUniqueValue.hash];
But my concern with this is if that the implementation of hash could change in an OS update. Yea, I could hash myself, but my question still stands: is there no way to just make a unique constraint in the database for a custom field?