BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

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 Guardsquare

SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.

Learn more

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.