Under the Bridge

Tools: Clang

So we’ve mentioned the LLVM/Clang Static Analyzer already in passing, but there’s enough resources springing up all over to merit some more attention:

Bug Finding With Clang: 5 Resources To Get You Started has usefully descriptive links.

Automated Clang From Xcode has an AppleScript to enhance the convenience.

And for the ultimate in convenience, here is AnalysisTool: a GUI application which allows running both official and their custom analyses!

Well, we wouldn’t want to recommend anything without actual personal experience, so let’s run it over the project we submitted to Apple end of last week…

… OMFG!! 145 — ONE HUNDRED FORTY-FIVE — BUGS!! OK, deep breaths, deep breaths, let’s look at what they are. OK, those are in libvorbis, not actually a problem; and these are in libfaac, nothing immediately fatal there either; and libflac has some too, again no need to panic; and precisely one (a shadowed variable in framing.c, since you asked) in libogg.

And in my source … not a single one. No, not ‘just false positives’, actually no not a single quibble anywhere. We’re not completely certain if that makes us actually as clever as we’d like you to think we are, or just utterly OCD on our coding hygiene. Of course, there’s always the both option isn’t there?

In any case, we thoroughly recommend that no matter what you’re programming for, you familiarize yourself with Clang!

Continue Reading →

Tip: iPhone Virtual Memory

“What?” you’re no doubt thinking, “is he going on about? Everyone knows there’s no virtual memory on the iPhone!”

Ah, young padawan, let us correct your misconception. It turns out that, indeed, there actually is. Take a look through this moderately amusing rant about the indeterminacy of memory allotments on the iPhone and into the comments. There’s a variety of suggestions about killing other processes, hogging memory to your own process, and in general going out of your way to not play nice with others; which, well, that’s not the iPhone way, is it now? But then, there’s this piece of solid gold:

There actually is a virtual memory system pager. However you have to manually set it up.
Search for ‘mmap’ in Apple’s iPhone Developer Forum and you’ll find a very informative thread.
Basically, it works like this: In place of malloc, you create a file of the appropriate size and then memory map that file using mmap. The virtual memory pager will page in and out the memory pages as needed. This works both for read-only data (you can just use [NSData dataWithContentsOfMappedFile: ] for that) as well as read-write memory.

Woah. We were utterly and completely unaware that was supported on the iPhone. mmap FTW!

h/t: iPhoneKicks!

Continue Reading →

Code: GLGestureRecognizer

This looks nifty; a gesture recognition implementation for the iPhone!

GLGestureRecognizer is a Objective-C implementation of the $1 Unistroke Recognizer, a simple gesture recognition algorithm. It was implemented over the course of a couple evenings in late April 2009 by Adam Preble.

Not that we actually have any immediate use for it, but hey in case something comes up, the code is on github and open source, so there you go!

[EDIT: And the very next day, Mobile Orchard has a post on iPhone Circle Gesture Detection too!]

Continue Reading →


Ah, here’s another fine job well done: “POssO” the one and only OpenSSO administration application for the iPhone is now live!


POssO adds the much desired remote management feature to your corporate identity management infrastructure, enabling you to achieve better efficiency and accessibility in your organization.

With features like:

1. Create Identities

2. Manage Identities

3. Search Identities

4. Password Management

5. Role Management

6. Policy Management

7. Session Management

8. Cisco VPN Client Support

You can manage your corporate profile remotely adding flexibility to your schedule. It will revolutionalize the way you manage your corporate identity management infrastructure.

Rather narrowly targeted, yes, but hey if you have a use for it … grab it now!

Get POssO

And we’re particularly tickled to note that after more than a dozen applications, the TrollSheep has finally made it into the UI for one of them … check the credits!

Continue Reading →

Pledging for icons

As you may have noted previously, the artistic skills are not ones of noted accomplishment by trolls. (Aside, that is, from performance art. We’re real good at that, as pretty much anyone who’s met us will attest, we trust.) So we were pleased as punch to stumble across this cleverly named site with a set of nice-looking free UIToolbar/UITabBar icons! We’ll download those immediately, yes…

But wait, what’s this over on the side?


a “kickstart”? What is a “kickstart”? Well, it turns out that Kickstarter.com is


Kickstarter is a funding platform for artists, designers, filmmakers, musicians, journalists, inventors, bloggers, explorers…

Now that’s intriguing, isn’t it? Here’s the details, but the basic upshot is it’s a website for organizing pledge drives. If enough people sign up to reach the pledge amount, everyone pays their pledge, if not, no one does. An interesting concept, and certainly looks like it has more potential than a donationware model.

So the designer fellow has a project page there where he offers rewards for various levels of pledging, starting with

I make cool icons for iPhone developers at http://glyphish.com and if I can collect $500 in donations, I’ll release the whole set of icons in vector format (SVG + Illustrator) for use in apps, posters, tshirts, whatever!

And that has worked out pretty well for him; it was up to $685 when we arrived, and hey we did think the icons were pretty nice and we were curious to try this Kickstart thing out besides, so we kicked in $20 to see how it went. Which was smoothly. So the nifty idea here appears to be implemented competently, which is always a nice bonus.

So, that certainly is an interesting alternative to consider for funding your development … or anything else … isn’t it? There’s a wide variety of different kinds of projects to explore, but we note with particular interest this project to accumulate enough pledges to remove ads from this iGoozex app. Which, well, we have no use for ourselves, but we’ll certainly be checking back to see how that works out for this fellow with people who do, and if it looks like this concept has some hope of working for developers as well as artists, we’ll see about trying this idea out for some project of our own perhaps. It certainly would be a nifty way of prejudging actual user interest in an application concept!

Continue Reading →

Style guides

So, you ever looked at your project with old stuff and new stuff and samples borrowed from hither and yon and thought “sheesh, I seriously need to sort out a consistent style here?” Yeah, us too. So here’s a list of resources to help you out with that.

As always, start at the mothership and check out Coding Guidelines For Cocoa and The Objective-C 2.0 Programming Language.

Then, visit CocoaDevCentral for Coca Style For Objective-C, with a second part as well.

Got some strong opinions now? Good, it’s time to read through this thread on the possible pitfalls that await a poorly chosen strategy of variable naming.

And whether you agree with them or not, it would behoove you to be familiar with the practices in the Google Objective-C Style Guide, part of the google-styleguide project to document the practices used in Google code.

That we believe is a fairly comprehensive rundown of Objective-C focused resources, but then there’s the style of the non-objective bits of C and C++ that will probably be part of your projects as well; and there’s quite a bit more of that around. But a quite sufficient resource for that can be found at this archive of coding style documents. And if nothing you find there fits quite right, why, here is a generator for your own personal style document. We must find some time to play with that one of these days!

[EDIT: And for actively beautifying code, check out this post on use of uncrustify with Xcode!]

Continue Reading →

Resources: Core Data

So not all that long ago we put together a list of resources for getting into the gritty details of SQLite for your iPhone data management needs. And as chances are you’ve heard, that’s all unnecessary now because the awesomeness which is Core Data will be available on iPhone OS 3.o. Sooooo, as soon as you can target OS 3+ only, it behooves you to get up to speed on it!

First off, here’s a brief concepts overview to get you started.

Then visit Cocoa Dev Central for the exceedingly worthwhile Class Overview and sample application walkthrough.

Then go trawl the mothership for Officially Sanctioned resources, starting with the Programming Guide.

As always, cocoadev is a great resource for anything related to Cocoa, and Core Data is no exception.

A variety of interesting Core Data posts at Cocoa With Love.

And another good collection at Cocoa Is My Girlfriend.

And speaking of CIMGF, the great folks at Pragmatic (have you got their Core Animation book yet?) are bringing out a book on Core Data in the near future by Marcus Zarra of that blog, and based on what we’ve seen from all involved so far we’ll just go out on a limb here and recommend that you’re absolutely certain to find it invaluable and you should just click the picture and preorder it NOW!


[EDIT: And there's a new tutorial series starting here that looks worth following as well.]

Continue Reading →

Tutorial: JSON over HTTP

We’ve mentioned the json-framework project before; but here’s an excellent tutorial on how exactly to use it that you really should not miss if that’s something you need to do.

Also note this other alternative, ObjectiveResource, which handles both XML and JSON deserialization in the context of interacting with Ruby on Rails applications, a port of Ruby’s ActiveResource apparently…

h/t: iPhoneKicks!

Continue Reading →

Snippet: Singletons

So there was this thread about using the Singleton pattern, and it went right quick into the usual whining about it being an anti-pattern and all, but there were a couple interesting links that turned up:

Singletons, AppDelegates and top-level Data is a good Cocoa-centric overview of the topic, and we direct your attention particularly to the SynthesizeSingleton.h header provided, which macroizes all the support you’d need if you wanted to use a singleton with conventional allocation semantics. Which strikes us as unlikely, but hey.

The interesting part though is the allocation question. The above-linked file relies on the @synchronized directive in allocation, which we think is a little unwieldy, as well as being Objective-C 2.0 dependent. So how to ensure thread safety then? Interesting discussions here, and here, and here, and here; that OSAtomicCompareAndSwapPtrBarrier idea strikes us as particularly nifty.

But here’s our idiom for setting up singletons; just do it at static initialization time, like this for initializing application settings:

static PMPESettings* _sSharedSettings = [PMPESettings sharedSettings];
@implementation PMPESettings

+ (void)initialize
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[[self sharedSettings] load];
[pool release];

+ (PMPESettings *)sharedSettings
if (!_sSharedSettings)
_sSharedSettings = [[self alloc] init];
return _sSharedSettings;

- (void)load
... if there aren't any saved settings, fill in defaults...


So long as we’re not doing ridiculous things at static initialization time — and oh boy, have we got some stories we could tell you about things we had to port that were completely dependent on Visual Studio’s link order! — but just sorting things into usable states, like above where -load creates default application preference values when none exist, this seems to me to be a perfectly reasonable way to leverage compiler and Objective-C semantics to sidestep synchronization worries completely. What do you all think?

h/t: iPhoneSDK!


And if you want to read lots of advice on singleton implementation…

Ship-It Saturday: PRHEmptySingleton repository

Objective-C Singleton Class Template

Everyone has a singleton, and this is mine

How I do my singletons

Require OS 4? Hey, guaranteed alloc safety: Singletons: You’re doing them wrong

This looks like pretty much the final, universally compatible, word on the subject: Objective-C Singleton

Continue Reading →

Tips: Localization

Heh. This fellow with, apparently, way too much time on his hands went digging around in AppKit and found out that there’s an undocumented call _NXKitString that lets you cheat on your localizations by accessing AppKit.framework’s tables directly.

Now, we really really don’t recommend you ever ship anything using that, but it is interesting to note the source of these tables:

To see what’s there, navigate to the following location:


From there, you can navigate into the English.lproj directory, for example, where you’ll see a list of string table files, all of which have the suffix “strings”. These represent the allowable table names that you pass to _NXKitString. So, “Preferences” maps to Preferences.strings and so on.

So not only can you save yourself some pennies on your own translation costs by digging through there, far more importantly, for any particular string that happens to be there, you can get The Official Apple-Approved translation … as opposed to the real howlers completely inconsistent with the rest of the system that your commissioned translators have a way of throwing at you, one finds on occasion. Because they always claim yes we are completely familiar with Apple conventions in all the languages you want … but that does not always turn out to indeed be the case.

While we’re discussing localization, if you have 23 localizations to spit out RIGHT NOW! like some of us do, here is a new addition to our Invaluable Development Tools list, LangSwitch:

The only boring and time-consuming solution is to thoroughly test the new UI in every localization before releasing. This is especially time-consuming as you have to change the language settings in System Preferences every time you want to change the localization.

Also, another downside of this is that it changes your whole computer (well, just your session, but whatever…). I personally don’t really like to use a computer in Chinese…

That’s where LangSwitch comes in… It gives you a simple GUI way to switch the localization for only the app you’re testing. It displays only the localizations avaiable for your app. Here’s an easy way to test your different localizations without the hassle.

Is that sweet, or what? Works just as described, and somehow manages to maintain the designated localization even after an Xcode Clean All and rebuild. Not completely sure just how it’s managing that, but it’s certainly a useful trick!

And here’s a useful little tip for the use of genstrings if you like, as we do, to organize your source in folders; this command will recurse two levels down your hierarchy to pull out all your source strings:

genstrings *[hmc] */*[hmc] */*/*[hmc]

To finish off, here’s a few other recent useful posts regarding localization you may wish to also read over if this happens to be a concern of yours at the moment:

ibtool: Localization Made Easier

Localizing iPhone Apps – Internationalization

Cocoa Localization Guide

[EDIT: And here is a web service that might be worth your looking into!]

Continue Reading →
Page 91 of 114 «...6070808990919293...»