Autechre + Great Divide Sampler + Objective C == Nirvana

15 Nov 2010 – Denver, CO

Honestly, it was. It was like the early 90s all over again – I might as well have had Poland by Tangerine Dream on the stereo and been hacking away at some Amiga 68k assembler, whilst connecting to a Razor 1911 BBS on my trusty 14.4k US Robotics HST modem (which cost me a fortune back then). I have to say I miss those days. Nonetheless, I managed to get pretty close to that feeling on Saturday night with some iPhone coding, a few of these bad boys:

Great Divide

And this on the stereo:

Autechre Amber

No sine-waves or fun demo comps this time, instead it was some daft Objective-C issue that took me to endorphin-land. All I wanted was to be able to check/uncheck a ‘Same As Billing’ field in a registration form, and have the form modified accordingly. Hardly rocket-science, right ? Think AJAX inserting some additional fields into an HTML div. I basically wanted the same thing on the iPhone.

In short, we just want things to look like this when the checkbox is marked:


And this when its not:


Pretty standard UITableView stuff, we need to:

1. Add ourselves as a UITableView delegate

@interface RegisterViewController : UIViewController <UITableViewDelegate>,

2. Implement didSelectRowAtIndexPath

- (void)tableView:(UITableView *)view didSelectRowAtIndexPath:(NSIndexPath*)newIndexPath

3. Insert & Delete the required sections/rows accordingly

[view insertSections:[NSIndexSet indexSetWithIndex:5] 

Everything worked just peachy, except when I’d try to ‘re-check’ what I’d just unchecked. At that point, it would appear that only a subset of the rows I wanted inserted, would actually appear. In fact, just the last one:


I spent several hours banging my head against the desk (i.e. drinking more beer), to eventually figure out that it was becomeFirstResponder. I was inadvertently setting each field I created to be the first responder, and it appeared to be working fine, except when I tried to dynamically insert sections/rows and it got very confused.

Some additional care taken when setting becomeFirstResponder, and its all good, got a nice buzz going and it was time to watch this documentary.


Which was epic :)