0

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.

https://stackoverflow.com/questions/11025469/ios-syncing-using-a-state-approach-instead-of-just-reacting-to-events

https://stackoverflow.com/questions/11037930/viewcontroller-when-viewwillappear-called-does-not-always-correctly-reflect-stat

Any ideas that anyone might have to very much appreciated.

Thanks,

developerDoug

1 Answer 1

1

If you're downloading the data for syncing using something like NSURLConnection, there are delegate call backs for when the connection is made (sync started), data is being downloaded (syncing) and data has finished downloading (sync finished). Even if you're not using NSURLConnection, specifically, most asynchronous web connection frameworks have this same sort of delegation pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.