Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

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

http://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

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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