Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Fun things I learned in Objective-C and Cocoa Touch this week

I spent this week re-writing the application I’ve been working since late-October. It was the right choice — the original app was full of cruft. Way too much cruft, I felt, for a codebase that had only been in existence for three weeks. The new code is much more elegant and should be easier to maintain and expand.

Anyway, on to the fun stuff:

Dot Syntax is awesome.

I’ve been working with Apple’s Utility app template, which includes an info button overlaid on the main view by a separate view. In the old implementation, I went and wrote several methods across multiple classes to hide this button to accommodate the presentation of a couple of overlaid views. I’ve been using dot syntax a lot in the rewrite to set various properties, and so decided to try the following:

appDelegate.rootViewController.infoButton.hidden = YES;

And it worked! I can set that property from any other class instance once I set:

appDelegate = [[UIApplication sharedApplication] delegate];

I couldn’t figure out at first why the various templates defined other classes as synthesized properties. Now I get the power behind it. I also don’t understand why Aaron Hillegass poo-poos dot syntax in his otherwise superb text on Cocoa development. This stuff is incredibly useful and much more satisfying than using brackets to set/get.

I also learned how to avoid the urge to hang myself when writing UITableViews. Hint: use C enums. Thanks, Fraser Speirs.

Leave a comment  

name*

email*

website

Submit comment