I’m attempting to query the CloudKit database for the following –
(Example)
userName = “Fred”
Let’s say that this is unavailable (checked with a query), so I want to find names which begin with “Fred” and end in digits, eg, “Fred1”, “Fred12”, “Fred126”, etc, so I can suggest the next available “Fred” option. Since it doesn’t seem possible to use a MATCHES query with a regex in CloudKit, is there an alternative? It would seem ludicrous to have to fire off 10 separate queries like so –
NSPredicate(format: "userName BEGINSWITH %@", "Fred0")
NSPredicate(format: "userName BEGINSWITH %@", "Fred1")
etc
Plus it’s not reliable, eg, if there’s a name such as “Fred12Smith”.
If anyone has any idea how to solve this, I’d be very grateful.