Under The BridgeUnder The Bridge

Bandwidth Testing

[EDIT: Discontinued.]

Here’s a handy tool for simulating slow network connections:

speedlimit is a Leopard preference pane for limiting your network bandwidth to one of a couple different speeds—768k DSL, Edge, 3G, and Dialup. This is really handy for testing your iPhone app under normal Edge network conditions in the iPhone Simulator. The new version allows you to restrict the slowdown to only a specific set of hosts.


Download it here or check out the source code.

h/t: iOS Development Goodies!

Numbers Posts

So in case you missed @rwenderlich‘s tweet, here is an informative article if you’re interested in

Everything You Need to Know About Being an Android App Seller

The money quote, or more appropriately the lack of money quote (Ha-ha! We slay us, we do!) is:

… even high-profile, highly rated Android titles generate “much lower” revenue than iPhone equivalents. Despite having one sustained top-selling $5 game (Retro Defense), a consistent fifth place seller (Battle for Mars) and being highlighted by Google, the company’s daily average revenue was just $62.39 for all its apps combined…

Ouch. Well, that certainly alleviates any annoyance we might have considered feeling that Canadian developers can’t sell Android apps YET (seriously, Google, WTF?) doesn’t it now? By comparison, this article says

… an iPhone app with a fifth place position in the App Store is predicted to earn about $3,500 per day, or more than what the same Android title would generate in 56 days…

Yep, 56x that’s a pretty big difference. Of course, most of us do not have a fifth place position anywhere in the App Store, at least not for very long. Here’s some numbers posts that we’ve idly noted over the last little while to give some more data points than that fifth place seller. Of course, we’d fairly confidently predict that anyone not at fifth place would find Android development just as comparative a massive debacle, but hey you never know.

iPhone App Sales, Exposed

Winning The App Store Lotto: What A Week At No.1 In The App Store Looks Like

Making A Living (Comfortably) On The App Store

Paperless So Far – The Apple App Store

The Anatomy of an Epic App Store Sale: 1.1M downloads in 1 WEEK

Big Mountain Snowboarding history and sales

Camera+ first month sales: Setting Sail in a Sea of Games


Story Tracker – A Year on the App Store

And for a full post-mortem on a really quite stunning indie game debut, check out

Chopper 2 Postmortem

Our most gracious thanks to all of those sharing their sales for our edification and fascination. And as always, if there’s any recentish posts of this sort we’ve missed, be sure to let us know!


[EDIT: Discontinued.]

Here’s a nifty UI enhancement for your scrolling views:

Do you like the way application images are displayed in AppStore or the way Safari flips between tabs? This post contains a complete horizontal, paged UIScrollView with preview control.

Alexander Repty posted a sample on his blog and my sample is based on his work. I’ve encapsulated the solution into one, easy to use, control…

In case you’re drawing a blank, the “preview” bit is to have items right and left show a bit of themselves as opposed to having each item full screen width, like this:

Screen shot 2010-08-06 at 11.34.46 PM.png

If that looks like something you’d like to try, read the post and grab the sample app!

Zeroing Weak References

So a couple of weeks ago there was this post

Friday Q&A 2010-07-16: Zeroing Weak References in Objective-C

… For this week’s Friday Q&A, Mike Shields has suggested that I talk about weak references in Objective-C, and specifically zeroing weak references. I’ve gone a bit further and actually implemented a class that provides zeroing weak references in Objective-C using manual memory management…

which was moderately interesting, if something we’d have to have a really clear need for before going to that much trouble; but the followup

Friday Q&A 2010-07-30: Zeroing Weak References to CoreFoundation Objects

is really interesting; there’s information on toll-free bridged objects and the structure of CoreFoundation classes there we hadn’t stumbled across anywhere else, and is most definitely worth a read through to get a better handle on how that black voodoo casting magic actually works behind the scenes. Besides, we just love stuff like this:

… Implementing this solution requires overriding the CoreFoundation finalize function. CoreFoundation has no supported mechanism for this, so I had to get down and dirty with the CF source code and hack my way in. This means that everything I’m doing is not entirely supported and could break, although I believe that this stuff is actually pretty stable…

Doesn’t that just scream ‘famous last words’ candidate to you?

… This kind of hackery is extremely challenging but it’s also a lot of fun. The CoreFoundation source code is a valuable resource for this kind of thing, but as always you must beware of private symbols which may change in the future. Other low-level open source code like the Objective-C runtime can also be a handy read. Finally, otx is an extremely useful tool for when you need to see how a library works when Apple doesn’t provide source…

Priceless. Next time somebody sounds off about our programming obsessiveness, we know exactly who to point to as an example that compared to real programmers, it’s like we’re not even trying.

Joypad Controllers

Here’s a few links for stuff that may be of interest putting together controls for That Next Great Game:


A collection of input methods for Cocos2d iPhone game development. It includes a Joystick, a dPad, and Buttons, all entirely skinnable and customizable…

The LevelSVG joystick code, separately available.

Good discussion here.

h/t: iPhone Friend via iOS Development Goodies!


So if you’ve haven’t looked into these new UILocalNotification thingys in iOS 4 yet, there’s a good introduction here:

iPhone Programming Tutorial – Local Notifications

but there’s a couple somewhat rough edges around them, unless we’re missing something:

1) Recurrence interval must be an CFCalendarUnit flag. Just the flag. So you can set something to recur every day, or every week, but not every three days. That seems rather odd.

2) Seems the application’s badge is always set to the number included in the notification, not the number of notifications that have triggered. So unless you go to the trouble of clearing out the pending queue and fixing the numbers in each of them every time the thing you’re notifying about is handled, or each time that something’s inserted in the queue of notifications, there’s no way to have the application show an accurate number of items pending.

Are we just overlooking stuff that’s completely obvious, Dear Readers, or are these actually the moderately annoying shortcomings which they appear to be?

How Social Games Ate Our Lunch

So you left as baffled as us by this whole Farmville thing? Here is an excellent article for you:

How Social Games Ate Our Lunch

… It’s unintuitive to think that games where you actually do not ever directly interact with another person could have a community, but what social games do is generate an asynchronous cloud of persistent community formed by the constant exchange of gifts, tools, and requests sent by other players. It’s generosity-driven, but transactional – if I send you a gift, I’m feeling happy because I helped you out (especially if I’m responding to a request you’ve put out), but I’m also hoping you’ll send me something back. And the more I send and receive, the more I plant, the more I return every day (or more than once a day) – the more hardcore my play becomes. Watch a hardcore FarmVille player. They move fluidly and attentively around the tiniest change in mechanics, and play not for some whimsical dollhouse experience but for tight, fast, controlled optimizations, seeking the fastest path to a clear goal, and putting in as much time as it takes to get there…

Okay, but we’re still not seeing, like, the point here.

… What World of Warcraft did to Everquest’s mechanics – making them smoother, faster, and more elegant, and so earning unprecedented millions of players – FarmVille, though we don’t like to admit it, did to World of Warcraft. FarmVille distills the active components of a game down to a handful of clicks, and massively leverages social and viral communication channels to create the feelings of shared mission and victory, all while carving out a player-expressed space in the online world. And while it’s doubtful that even its creators would call FarmVille “elegant,” it is the first step in a new evolution of games, new (and resented) the way World of Warcraft was in the beginning – and its mechanics are so powerful that it has compelled a head-popping number of new gamers even without being polished the way WoW was…

Yikes. We’re not completely sure whether to be flabbergasted or horrified at this evolution of gaming, because we sorta have the apparently old school idea that a game ought to be, you know, fun, and these seem a lot more like work, but hey, the argument does hold together well, so if you’re interested in game design it’s definitely worth a read!

h/t: @gaminghorror!


[EDIT: Discontinued.]

Feel like snooping around other people’s apps? Hey guess what, there’s an app for that:

atPeek is a developer tool designed to explore and display resources found in iPhone applications. Its simple and intuitive interface allows to effortlessly examine normally unaccessible application details. atPeek can export individual assets or entire folders and its unique feature is its ability to decode both crushed iPhone PNG images and PVR textures back into standard PNGs.

Even if you’re not particularly interested in other people’s stuff, these QuickLook plugins might be handy:

You can separately download the PngUncrush (32-bit and 64-bit Universal) and PvrUncrush (i386 only) QuickLook plugins, which we have developed for atPeek. Simply copy them to /Library/QuickLook folder and you will be able to preview iPhone crushed PNG images and PVR textures right from the Finder (or any other QuickLook enabled applications).

h/t: iOS Development Goodies!

Commercial cocos2d Code

So we’re pretty big fans of cocos2d around here as you’ve no doubt noticed, but today is a special day cocos2d-wise; it’s the two-year anniversary of our very first post about it! And the library certainly has been remarkably successful by any metric you’d care to measure, but for our anniversary post, let’s talk about commercial offerings for it, that being a particularly striking metric of success of an open source project. Practically unheard of, in fact.

But before we begin, lead developer Ricardo Quesada [EDIT: Used to] support himself selling two projects –

Sapus Tongue Source Code

Complete source to the “Sapus Tongue” and “Sapus Tongue Lite” games on the App Store.


A level editor for platform/labyrinth type games which parses SVG files created by Inkscape into a Box2D world. Samples of what you can do can be seen in “LevelSVG Mini Games” on the App Store.

Now, we could say some obvious stuff about how best practices for a library would come from the guy who wrote it, or we could mention how insanely responsive Messr. Quesada is to support questions, but let’s not bother with that because the important point’s rather simpler; if you’re making a buck off his work, buying these projects is the very least it’s decent to do.

Now that you’ve done that — you have, haven’t you? — let’s take a look at two commercial offerings that have sprung up, which we’ve gone and spent some C$250 on just so that we can report on them to you, Dear Reader, because we love you so much.

First off, there’s this fellow @gaminghorror who has set up a site learn-cocos2d.com and is writing a book on it; worthwhile endeavours the both of them you’d think, but in the interests of full disclosure there appears a certain chilliness in relations evidenced, seems there’s a perception that the code he’s selling and we’re about to review competes with the projects mentioned above. Well, we trust our feelings on your correct priorities are quite clear already, so if he’s offering something else useful we don’t really think there ought to be a problem here, diversity and proliferation are good, yes? Speaking out of total ignorance of whatever the actual history there is and just guessing from those links, we hasten to clarify.

Any-ways, on to that source code he’s selling; it’s called Line-Drawing Game Starterkit, it’s US$179 through, well, today, and then up to US$299. As you can guess from the name, it demonstrates a certain wildly popular genre of iDevice game,


and you can check it out for free on your iPhone or on your iPad in the App Store, or read the online documentation. As for us, we installed it, and that went smoothly, defining an Xcode source tree for the cocos2d distribution of your choice is it really, and compiling the iPad target against yesterday’s v0.99.5-beta cocos2d latest almost went smoothly except for a 4.0-only flag in CocosDenshion; we’ll assume that’s their oversight not making it 3.2 compatible for iPad, not something to hold against this project, and yes it up and ran just like the demo. Code is quite clearly written and decently documented, flipping through it and running clang only found a few things stylistically different from our preferred practices and nothing that qualifies as a serious issue.

So yeah, if you’re planning on a Flight Control knockoff, we’d say it’s definitely a fine investment. Otherwise, it’s a decent example of how to structure a project in iPhone and iPad targeting versions, but not overly compelling for the price is our initial impression.

Price, on the other hand, is definitely the selling point of our second product, The iPhone Game Kit; [EDIT: Now withdrawn] And in this case, it’s marketed as

… a complete, full-featured walkthrough to making your first video game on an iPhone, iPod Touch, or iPad. Even if you don’t have any experience at all, the Game Kit will guide you through your first lines of code and teach you everything you need to know to get your game going…

which does indeed appear to place it in direct contention with Ricardo Quesada’s offerings, and thus some skepticism of motivation is not unwarranted. But hey, you can always look at it as people who are brought into the platform by this might go on to purchase the other offerings later which are indeed somewhat intimidating to the novice no doubt; so we’re not going to rush to any judgement that there’s no redeeming value here. Besides, we dig the old school RPG thing and that’s what his demo ‘Quexlor’ is,


you can download it free as a universal iPhone/iPad version from the App Store to check out.

This download comes with a pretty basic “Publishing Guide” as well as “The Book”, a 127-page walkthrough of development, the Quexlor source, and using the Tiled map editor. And quite good indeed that one is, certainly quite a bit better than any other introductory level documentation we’ve seen anywhere. Moving on to the source code, this one includes its own distribution of cocos2d 0.99.4 so we just open the project and run it on a phone, yep works fine. Although ‘Build and Analyze’ comes up with 16 errors all of which look valid, more than a little sloppy there, tsk tsk. Flipping through it, the code looks decent quality but not as self-documenting as we like, loops like for(id o in ra) are the kind of thing we give our minions some choicely sarcastic observations on the value of maintainability as the highest metric of coding quality to aspire to when we catch them at it, but at least it is commented thoroughly. To the point where maintaining the comments would take significant effort actually which we’d say is rather overdoing it as your code should be adequately readable on its own, but hey it is aimed at beginners.

Soooo … whilst we’re not impressed enough to give this kit a wholehearted recommendation, [UPDATE: Well, yes we are as of version 3.0 now] and marketing it as “including” free content from other people both cocos2d and the game’s graphics is somewhat misleading (although granted he does provide attribution, just not prominently) it definitely is a good faith effort with significant value especially in the guidebook; hey, if we ever get around to writing That Great Turn Based RPG that we idly toss the idea of around every so often, we’ll definitely take this project as our starting point. And yes, if you know nothing about writing games and you want to start with cocos2d, it probably is pretty much the best thing out there for you.

So there you go, we figure both these options are good faith efforts and are likely a net benefit to the platform; somewhat more questionably in the second case, but it’s definitely appropriate for someone who needs a more gentle introduction than jumping into LevelSVG or the like straight off, and then they might go on to buy the more advanced stuff later. So you could argue that. Or, hey, just do what we do and buy everything! Sure, sure, some people say money can’t buy happiness … they just don’t know where to shop.

Custom UISwitch

So it’s getting along to Pretty Shiny Artist Time™ with your latest game project, and they come up with switches like this:


Note the non-standard metrics of the slide and the alpha halo surrounding the active area as particularly challenging obstacles to some kind of quick hack on the standard UISwitch. So we needed something custom to achieve the above. And here are the interesting looking UISwitch giblets we found for you to start with next time this kind of thing comes up:

CustomUISwitch found in homick/iPhone-Snippets is the one we ended up using; a kinda-close reimplementation of UISwitch behaviour, most notable exception being that it acts like a button with press triggering a slide animation, not the real UISwitch drag behaviour. But as the artist hadn’t provided an activated state for the slide, hey that actually solved a problem. Also it’s a bit odd that the author chose to create its own delegate for value changes, we had it just call [self sendActionsForControlEvents: UIControlEventValueChanged]; when appropriate, which fits nicely with Interface Builder’s control-drag default assignment for a UIControl.

If you’re looking for something that’s a really thorough and apparently exact behaving reimplementation of UISwitch, then we’d say that RCSwitch is probably your best starting point. Of course, that requires an actually appropriate set of component graphic pieces, as opposed to working off a superficial Photoshop mockup, so we went with expediency today.

An interesting alternative approach is UICustomSwitch which skins a UISlider instead of implementing off the UIControl base.

As a final treat, if you’d like to simply put a cute little icon on a regular switch’s slider, like this,


and you’re not nervous about making assumptions about the internal view structure of standard controls, then DSSwitch is the little tidbit for you.

As always, if you have any other UISwitch tidbits to share, let us know!