Under The BridgeUnder The Bridge

BDD Testing: Cedar

So let’s say you’re interested in Behaviour-Driven Development testing of your iPhone projects. But there isn’t anything to help out Objective-C like all the cool kids have, you say? Not so! Here is your introduction to Cedar:

BDD-style testing using Objective-C

… One of the things I found I miss most in testing Objective-C, Java, or C++, is the hierarchical structure for organizing tests that frameworks like RSpec or Jasmine provide. I find nested describes indispensable for managing orthogonal aspects of the classes under test, for handling preconditions, for eliminating redundant setup code, and for generally keeping my sanity. So, when I first heard about the addition of blocks in the GCC compiler for Objective-C the first application that came to mind was testing.

So, I wrote Cedar, a BDD-style framework for writing tests in Objective-C. The code is available here. Perhaps more importantly, Cedar is in its infancy so I’m interested in any suggestions and feedback. To that end, I created a public Tracker project for it here

and a followup post correcting people who thought it wouldn’t work for iPhone development:

BDD-style testing for iPhone projects

… I actually wrote Cedar specifically for testing iPhone OS projects we’re working on at Pivotal. To prove it, I’ve started a small public iPhone project that I’ve test-driven entirely with Cedar. You can get the project here (more on that in a bit); it should eventually allow you to log into Pivotal Tracker, see all the delivered stories in a given project, and accept or reject each one…

So that looks like that might be an interesting new development style to take up. Although, at this exact point in time, one might wait for that currently-NDA’d version of Xcode to be released before making any firm commitments…

h/t: iPhoneFlow!

Marketing: FreeAppADay

So chances are you’ve heard of FreeAppADay.com, where you get to pay them a whack of cash for the privilege of not making any money. Sounds promising, doesn’t it? But, you know, perhaps we are unduly cynical (it has been known to happen) and there is indeed a sound benefit to the exposure gained by this strategy, yes?

Well, as you can read in this iphonesb thread, not so much.

… Before the promotion, sales of Scribattle were pretty low; averaging 
4.5/day the month before the promo. Scribattle Lite, the always-free 
ad-supported version, averaged 432 DLs/day during that same time 
period (this roughly 1% ratio is incredibly regular for this pair of 
apps btw). During the promo period (It was free for most of a week), 
Scribattle jumped to about 75000 DLs/day, while Scribattle Lite stayed 
at normal levels.

Disappointingly, after the promo period ended, sales dropped directly 
back to their normal levels; Scribattle averaged 5 sales/day during 
the 30 days after the promo ended. There is a tiny bump on the day of 
switching back to paid, where just a handful of people probably surfed 
in while it was free, and it changed to paid while they were on the 
page, and they went ahead and bought it anyway. I’m really talking 
tiny, it looks like about 10-12 people, I made $28 that day.

I could be bitter and say I wasted my $600, but I don’t really see it 
that way. If nothing else, it was a learning experience…

No, no, go ahead, be bitter. You’ve earned it.

… And no, my sales spike was just a sharp plateau. Sales dropped off immediately to pre-FAAD-promo levels…

And on behalf of the rest of us, a heartfelt thank you for providing us the learning experience without it costing $600!

There is more mildly worth reading in the thread about possible ways to make this less of a mistake, but really the most important thing we see to take away from it is that free users are not worth a cost to acquire, indeed they are actually a negative to your paid app. This followup was particularly eye-opening:

… A vocal sub-group of them want everything to be both free AND perfect, and if it’s not, they’ll trash it loudly on the nearest available forum (in this case, the app store). In fact, acknowledging this fact, the guy from FAAD actually suggests having a post-FAAD-promo update at the ready, to help push down some of the inevitable trash comments that you’ll get during the free period (since those comments will belong to a previous version, and won’t show up at the top)…

Yikes! OK, we don’t know about you, but it sure seems to us that when a marketing channel has to provide you strategies for damage control of the effects of its use in advance, perhaps using it is a somewhat less than optimal plan, yes?


Why yes, yes there are counterexamples. Here is a pretty decent one (h/t : @fingerbakery). So there is a certain class of apps to which this promotion avenue may be fairly well suited, we’ll grant the no doubt very nice when they’re not miffed with us @freeappaday people, sure. But we stand by the important point that free users aren’t worth acquiring if you have anything other than a support-free little diversion of an app.

UIScrollView Menu

Here’s a detailed howto on implementing a useful-looking UI widget extension:

Digital Post, my newspaper app for the iPad, uses a number of custom user interface elements to build out the full user experience. One of these custom components is a horizontal topic selector that you can swipe and also tap to select individual topics…


Not terribly complicated, but a nice implementation, featuring just how easy it is to use UITapGestureRecognizer.

Tip: UITabBar Tint

So you may have noticed that unlike most controls in UIKit, there’s no way to mess with the tint color of a UITabBar. But let’s say you really really want to make your UITabBar look different: well, from the people who brought you that nifty BarTint tool, here’s how to go about that:

CGSize tabBarSize = [tabBar frame].size;
tabBarFakeView = [[UIView alloc] initWithFrame:
CGRectMake(0,0,tabBarSize.width, tabBarSize.height)];
[tabBar insertSubview:tabBarFakeView atIndex:0];
[tabBarFakeView setBackgroundColor:[UIColor redColor]];

… and apparently the buttons will get drawn acceptably on top of whatever color/image/whatever you stick a view in there for. We’d be just a teensy little bit nervous that the SDK Police might consider this “undocumented API”, having encountered issues of that sort before, but hey, if somebody really really wants their UI to look just so, there you go!

Instant Translation

Think it’d be neat to embed Google Translate facilities directly into your app? Well, in case you didn’t know, there’s a public AJAX Language API for that, and it’s pretty dead simple to put into your iPhone app:

Google Translate and iPhone apps

Only available while online of course, and chances are that there’s licensing restrictions that you’d better be aware of, but hey, free insta-translation of any sort is pretty nifty!


Ray Wenderlich now has, of course, a detailed tutorial on the subject:

How To Translate Text With Google Translate and JSON on the iPhone

Syntax Coloring

Here’s a good start for you if you’re tasked with writing a syntax coloring editor: The “vital pulp” (as they put it) of text editor Smultron, now being further developed as a fork named Fraise, is now packaged up as an Apache-licensed framework named Fragaria. (Where do they get these names from?)

NSTextView-based, so not of immediate application to your iDevice coding, but hey it’s something!

h/t: cocoadev!

Pull-To-Reload UITableView

So this may be old news to you, but the official iPhone Twitter client (née Tweetie 2) has a super-nifty interface enhancement where to reload your tweets you pull down the top of the list and it gives you a prompt to refresh. Pretty cool, huh?

Well, here’s an explanation with complete source of how to add it to your own projects!

How to make a Pull-To-Reload TableView just like Tweetie 2

Working implementation available for €20 with the My App Sales source, if you’d like that, but like most things, it’s pretty straightforward once someone shows you how.

… and apropos of discussing things Twitterish, should your image there be of large concern to you, you might find amusing/educational this semi-rant: Elements Of Twitter Style. Whilst personally we haven’t actually embraced Twitter past installing Duane’s nifty WordTwit plugin to treat it as an alternative RSS feed essentially, we’ve grudgingly acquiesced that there are some feeds out there with enough interesting content to bother devoting a modicum of attention to. Yeah, we know, doesn’t sound very much like a troll, getting involved in anything social media-ish, does it. Cha, what next, signing up for Facebook? The horror!


Here’s another simple and free implementation: iPhone Pull to Refresh!

And another: EGOTableViewPullRefresh!

Yet another: SSPullToRefresh!

h/t: @rwenderlich!


Yes, it’s that time again, time for another chef-d’œuvre from the troll kitchen; and today the main course is something a little different, a step into the world of politics. Specifically, the upcoming Toronto mayoral election. No, seriously, the upcoming Toronto mayoral election. Presenting … “iRocco”!


Now, just in case anybody happened to miss this before, Galactic Troll HQ is in downtown Vancouver, and that is a long ways from Toronto. We have absolutely no idea what the issues are in the Toronto mayoral race, nor do we have any idea of how Messr. Rossi stacks up against his competitors …

… other than that quite obviously his campaign has the most discerning taste in iPhone developers compared to whomever that competition is! And since we can’t think of any other way other than choice of iPhone developer in which the office of Toronto mayor could possibly affect us, well that’s quite enough to merit The Official Troll Endorsement, isn’t it now?

(If, on the other hand, you need some other proof than “has a troll produce their iPhone app” of the manifest suitability for high office of a political candidate — although we certainly can’t imagine why! — then here is the campaign website for you to figure it out for yourself.)

And we do have a warning for anyone planning something along these lines, specifically that includes a “Donate” page: You know that bit in the agreement, section 3.3.21 to be exact, where it says

Your Application may include a direct link to a page on Your web site where you include the ability for an end user to make a charitable contribution, provided that You comply with any applicable laws…

Now, it says “a direct link to a page on Your web site”. Is it not reasonable, we ask rhetorically, that to take a URL and load it into a UIWebView should qualify as “a direct link to a page on Your web site?” Well …. not so much, it turns out:

Donations are not permitted to be taken within the application, however it is possible to provide a donation link to your web site. This link is required to open Safari to collect the donation. We encourage you to make the necessary changes to your application and resubmit it for review.

Begosh and begorrah! What, we ask, WHAT is the significant difference between “load it up in a UIWebView” and “required to open Safari”? Mutter, grumble. Well, now we know. And hey, at least it wasn’t rejected for anything actually wrong with the code.

So there you go. Should you have any interest in the Toronto mayoral race, Dear Reader, you know what to do!

[POST-MORTEM: Now withdrawn from store…]

C99 Tricks

So you think you know the C programming language? Well, we’ll just betcha that you’ll find out something new by checking out

Fun with C99 Syntax

The C99 language added some pretty neat features to the ANSI C we know and love (now known as C89). I used a construct called compound literals in my iPad Dev Camp presentation, and it seemed new to a lot of people. Here’s a summary of some lesser known features about C99 that are worth knowing. And, since Objective-C is a strict superset of C, all this applies to Objective-C, as well. Best of all, as of recent Xcode (3.0? 3.1?), C99 is the default C dialect for new projects, so you don’t need to do anything to start taking advantage of these…