UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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.

1      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.