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

Synchronizing equatable instances of the same object

Forums > iOS

I've got an app-architecture question, and I'm working with an older code base so bear with me.

We have a Theater object that represents a row in our database with a unique field, theaterId. As our app is pretty large, we have several pages that could instantiate an instance Theater after a request to our backend, and that new instance of Theater could have the same theaterId as another instance that is currently in memory elsewhere in the app. (i.e. theaterOnPageA == theaterOnPageB)

Based on the constraints of having to modify a large codebase that is split between Objective-C and Swift, I am currently trying to keep these instances in sync using NotificationCenter to publish notifications whenever an instance of Theater is updated, however, this has been less than ideal and requires a lot of cognitive overhead to debug.

I was wondering if this was a common problem throughout iOS apps that could be solved with a tried and tested architectural pattern?

3      

Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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.