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 Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.