I am currently working on a business application that needs to check for the latest XML report that is available. The report is normally published at a fixed day every week however this may change due to updates. The XML report has a fixed URL with two changing parameters, year and month.
I have a working logic that uses the current date and extract the year and weeknumber and use this as parameters in the URL. Then I instantiate a NSXMLParser object with the URL and checks whether or not the NSXMLParser throws an error. If it does throw and error the current week is subtracted by 1 because the report is published in the middle of the week so it retries with the url but now with weeknumber – 1.
I know this is fairly bad way of doing it however at the moment a push service which probaly would be a much better way of doing this is not an option in the first version.
So my question is if the approach already done in my app is an OK way of doing it in the first version? Or is a better way to check if a resource on a webserver is available, and if it is not retry in a loop with weeknumber – 1 in the URL path.
Thanks in advance!
If you have control over your web server you could define a fixed URL that will always return the week number of the latest report available.
If you don’t have control over your web service your approach sounds like the famous bad provisional porkaround that will be alive on for eternity simply because it gets the job done 😉