Best way to update UI when dealing with data synchronization
Posted
by
developerdoug
on Programmers
See other posts from Programmers
or by developerdoug
Published on 2012-06-15T03:23:59Z
Indexed on
2012/06/15
15:26 UTC
Read the original article
Hit count: 249
I'm working on a bug at work. The app is written in Objective-C for iOS based device, for the iPad. I'm the new guy there and I've been given a hard task. Sometimes, the UIButton text property does not show the correct state when syncing. Basically, when the app is syncing, my UI control would say "Syncing" and when its not syncing it'll display "Updated @ [specific date]". Right now there is a property on the app delegate called "SyncInProgress". When querying / syncing, occurring on background thread, it updates a counter. The property will return a bool checking expression 'counter > 0'.
There are three states I need to deal with. Sync has started. Sync is updating tables. Sync finished.
These items need to occur in order.
My coworker suggested to take a state based approach instead of just responding to events. I'm not sure about how to go about that.
Would it be best to have the UI receive a notification to determine what state its in or to pull every so often if state changed?
Here are two posts that I put on stackoverflow, in the last few days, that relate to this.
Any ideas that anyone might have to very much appreciated.
Thanks,
developerDoug
© Programmers or respective owner