Remember, remember, the month of December

It’s been mildly annoying for a while – how iOS, and UIKit in particular, treats even the most irrelevant little deviation in input data as a hard error and throws an exception, instead of just logging the problem and either ignoring the request or adjusting the input parameters.

This morning it became *really* annoying, but I’ll get back to that in a minute.

You may argue that the hard error causes more of these issues to be fixed by sloppy developers who would otherwise ignore the warnings and release code that, strictly speaking, isn’t correct. This is a fair argument but I really think it should be limited to debug code.

The problems I have with throwing hard errors on a visual rect that is 2 pixels to wide or, say, a “scroll to index path” that has an invalid path (and this is what I will be getting back to, shortly), are:

1) The exception is caught at application level, and stops execution so further debugging is not possible. As a result, locating the actual code can be tedious – especially for cases that are not easily reproduced. If it had been a warning in the log, it would often be possible to step back and reproduce the action while the app is still running.

2) When this happens in released code you crash an app because of a glitch that would, in many cases, probably not even have been noticeable.

And (2), of course, is why I am even writing this – I got bit by this today, badly, as I realized that TempusCura basically does not work for the entire month of December.

The reason?

Well, as a courtesy to the end-user, the calendar view automatically scrolls to the current month when opening the main view. The current month, obviously, is a number from 1 to 12. The indices in the table that is showing the months, however, are 0-11. Now, for all other months, this creates a small offset as the view actually centers on the next month rather than the current – I never noticed this, and neither did anyone testing the beta version of the app. When you get to December, however, UIKit throws an exception because the index 12 is illegal for an index range of 0-11.

This is not really a critical feature in any way, yet it turned out to be a major showstopper, as the app is completely unusable for the entire month of December.

Yes, I know it’s a bug on my part, and yes, maybe I should have tested all uses cases for all days of the calendar year, but we all know how realistic that is.

Yet, if UIKit had not been so anal about these utterly irrelevant details, and simply showed January, or capped the index at 11, the app would have worked just fine.

And if Apple didn’t take 2 weeks to approve an app, the patch would already be on-line… Sigh!

** 2013/12/02 – UPDATE **

TempusCura is now available in V1.7.13 which fixes the December crash. Hats’ off to Apple who got the app reviewed and approved in just one day! Awesome :).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s