NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Prevent duplicate records in Core Data & CloudKit?

Forums > SwiftUI

Hi there,

I'm hoping someone can help me.

I know that CloudKit doesn't allow the use of unique constraints, but in my SwiftUI IOS app, I wanted to have an entity with a couple of attributes that are not allowed to be unique, and I wondered if that were possible?

If this were a web app, I'd search the database for records prior to allowing users to save, but I can't figure out how to do that in SwiftUI's stateful way of doing things. There was a tutorial on hackingwithswift about doing dynamic FetchRequests that looked like it might work but I couldn't figure out how to apply it to my situation.

If anyone has any advice or code examples, that would be very helpful. Thank you.


Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.