Our DNA is written in Objective-C

Candid Steve Jobs at D8

Steve Jobs is one of the most interesting guests of Malt Mossberg at his All Things Digital D8 Conference. There is a summary of his Q&A session available, but the most interesting parts are the videos they posted. I compiled them into one overview here so that you don’t have to search for them and provided a summary for each.


Steve had the idea for a tablet without keyboard first and ordered his engineers to develop a glass multi-touch display. When they came back to him and showed him the inertial scrolling and rubberbanding he got the inspiration to do a phone first. So they shelved the iPad and later “when they got their wind back” returned to it and used what they learned on the iPhone.

Read more

BSA Banner

Saturday Morning, Breakfast, Wired eMag

I’ve always loved to read glossy tech magazines. In fact I feared that I would like them too much to be unable to throw them away. When I was young I had an extensive collection of P.M. (a German popular science mag) that came right to fill the hole that selling my Mickey Mouse collection had left. So I wend cold turkey, no subscription only buying on vacations, as to avoid assembling high towering stacks of paper.

With the iPad I fulfilled my first dream of having a PADD like Jean Luc Piccard, so it was no question that I had to purchase the first digital WIRED app/magazine that came out last week. Many people rambled about the price tag, $4, but I think that’s fair, because you get way more value than you would in paper. Let me share my impressions and let’s peek under the hood of the first eMag that deserves to be called that.

Sipping a fresh espresso with a bit of cream, browsing through the Wired eMagazine. Let’s have a look at how it is to read it and look behind the scenes to see what we can learn from it as iPhone/iPad developers. Maybe there’s an eMagazine of our own in our future?

UPDATE: Here’s Adobe’s Promo for the Magazine. Adobe has announced that soon there will be software on Adobe Labs to do do what they did for WIRED for any InDesign publication.

Read more

Making Your Own iPhone Frameworks. In Xcode.

Back in April Oliver wrote an excellent article entitled “Making Your Own iPhone Frameworks”, in which he explained how to do what many developers still proclaim as impossible: how to create custom frameworks that you can use in your iPhone apps! I would recommend that you read Oliver’s article first, especially if you’re wondering what a framework is… or, possibly, why you should consider making your own frameworks. I wont talk about that here :).

To build frameworks Oliver wrote a simple shell script that first creates a typical framework bundle, and then copies resources into the appropriate directories. In this followup article, I’ll show you how to create the framework bundle entirely within Xcode, without any scripts, plugins, product-, or package-types. While this has a few advantages, I’m not claiming that my approach is in any way perfect, and there may be problems that I haven’t encountered yet. As always, this is a work in progress, so if you have any suggestions, please feel free to leave your comments below.

Enough talking. Lets get started –

Read more

Renewing Certificates and Provisioning Profiles in under 10 Minutes

Once a year you are required to refresh your two certificates and all provisioning profiles that use these. Mine had expired and so I made a screen capture to show you how painless the renewal process can be. At the same time it also shows newcomers how to best set up their stuff on the provisioning portal.

Hint: if you find that the Submit button is not working, you can also go into the provisioning profile name field and hit Enter.

For regular development work it’s generally sufficient to have only 3 provisioning profiles:

  • “Development” – uses your “iPhone Developer” certificate, a * wildcard app identifier and all your development devices
  • “AdHoc” – uses your “iPhone Distribution” certificate, a * wildcard app identifier and all devices you want to do ad-hoc builds for
  • “AppStore” – uses your “iPhone Distribution” certificate, and if you don’t do IAP or Push Notifications you can use a wildcard app identifier as well

You don’t need to create a new app identifier on the portal for each new app that you begin. You only ever need unique app identifiers if you publish an app capable of InAppPurchases or Push Notifications.You can change the app identifier with every upload to Apple, contrary to the bundle identifier in the info.plist which has to stay the same for the app to be accepted as an update. New bundle identifier means new app.

Once you have gone through the steps shown in the video you are good to go for another year, until the certificates expire once more.

World Cup Pools App

In case you where wondering … I was busy with an app I did in cooperation with Andreas Heck of der.heckser. According to my time tracker I spent 87 hours on it to get it to version 1.0 and yesterday, after twoandahalf intense weeks we sent version 1.0 to Apple for approval.

Let me give you a VIP tour of the app, first showing off the prettiness and functionality of the app itself:

After that, the second part shows you how my Xcode project looks like and I’m explaining some of the hurdles we had to overcome. This is for you beginning developers out there, but I’m hoping – if you are a seasoned pro – you still might find it interesting.

For an app like this it is essential that you spread the work amongst several people if you want to be able to finish it in about two weeks. When I get asked by new customers I am always responding “I’m a programmer, not a designer”. That’s actually bending the truth. I could probably design a decent app if I wanted to. Although my personal method of designing apps is to: build it, try it, improve it, rinse and repeat. That’s the kind of approach which is hard to get paid for, especially if the typical customer is not willing to pay more than a thousand dollars a pop.

The second thing I generally try to avoid is server-side work. I have done a bit of VB.NET programming on my server and I could do most of the things I would need, but I just hate it. Cannot tell you why, I’m in love with objective-C and anything else feels wrong to me. And any app that is social or needs the cloud to work needs a server to run off of.

Often customers are not aware of these two factors, and the different skillsets necessary.

I was glad that Andreas Heck approached me for a partnership where I could do what I do best. And he did that with sufficient funds to get the project flying. I mention currency as one of the essential ingredients because generally funding is what makes or breaks an app. Sure, you can write apps in your spare time, but then they are ripening in months, not weeks. Not a chance getting it done before this year’s soccer world cup.

Also if you’re a full time iPhone developer like me, then two weeks of non-stop work mean that you have to make have of what you need to sustain yourself financially in that time. Otherwise you have to divide your attention between a project like this and a well paying one.

It’s as simple as that: there there are some areas where you are way better than others. Money buys you the difference in time. This project has again proven to me that great apps need a team, even if it’s just two people.

UPDATE: The regular version of the app was approved by Apple on June 2nd after requesting that we remove “FIFA” from the list of keywords. We used this as an opportunity to fix a couple of minor bugs and raise the version to 1.0.1:

  • FIXED: Potential crash after user creation
  • FIXED: Inconsistent use of … and > on tableview cells
  • FIXED: Invitations to Pools would show with a %20 instead of a space
  • FIXED: Issue with animation going straight to entering an e-mail
  • FIXED: Some too long German expressions

The pro version is still under review, but you get the same functionality if you purchase the normal version and then use In-App-Upgrade to Pro.

Available on the iPhone App Store

NSNotifications and Background Threads

I’m coming out of highly concentrated work (approx 87 hours) on my latest project. It’s an app that allows you to organize a betting pool for the upcoming FIFA World Cup.

The simplest method of communicating with our web-based API we found to be having the server send array or dictionary PLISTs which I could load and parse in a single line of code synchronously. So first I created all the API calls in synchronous blocking mode. When they where working I added a method by the same name prefixed with “async” and would have the blocking code executed on an NSOperationQueue.

If the synchronous method needed zero or one parameter then you can use NSInvocationOperation of calling it and have the queue work it off in the background. In some cases more than one parameter has to be passed. Here an NSInvocation has to constructed with multiple parameters, which I explained previously.

Once the API call is done processing it needs to tell the app about its result. This is done conveniently by sending NSNotifications. And in all the places in the UI where specific notifications should have an effect, you simply subscribe to the notifications by adding an observer for them to the default NSNotificationCenter. NSOperationQueue automatically uses multiple threads and takes care of the autorelease pool. So any operation might either run on the main thread or on a background thread.

Warning: Crash Ahead!

This causes a problem I have only ever seen happen on Simulator, so I’m not sure if it would also happen on the device. Generally you want the NSNotifications to be sent on the main thread as well, especially if they trigger UI activities like dismissing a modal login dialog. I don’t know if Apple will tweak NSNotificationCenter to send on the main thread in the future, but until they do, here’s my drop in solution.

Read more

Parsing an RSS pubDate

Andreas Heller asks:

When parsing an RSS feed I get a date from pubDate, but as NSString and not NSDate. How do I get a date that I can use for sorting?

That’s a problem you face quite often when dealing with dates which are encoded in XML, be it an RSS feed or any other XML-based file format that you would be getting via HTTP GET. Contrary to other languages where any properly formatted date can be automatically parsed we have to do this ourselves in Cocoa.

Fortunately there is the NSDateFormatter class which can do it both ways: from date to nicely-formatted string as well as the other way around.

Let’s do like a Unix-pro and get ourselves some test data by getting some pubDates from my RSS feed. In terminal type:

curl www.drobnik.com/touch/feed/ | grep pubDate

This gets us the pubDates from the 10 latest articles on my blog. We see that WordPress encodes the pubDates in this format “Mon, 03 May 2010 18:54:26 +0000”, not really a very easy to parse one I concede. According to the RSS 2.0 spec this is supposed to be in RFC822 standard. If anyone would ask me, personally I think that the inventor of this date format should be poisoned, then hanged and maybe shot for good measure. Who in his right mind would create a date representation that does not allow for string sorting?

Read more

Meta-Calling Multi-Param Methods

Objective-C has several powerful methods of working “Meta”. Besides of handling methods and objects themselves you can also save a method’s signature in a variable, and call it later. That’s a “selector”. Or you could construct an object representing the entire call of a method, including one or multiple parameters and then use this object in place of the actual call.

Why would one do such a complicated thing? Well, there are several pretty useful scenarios where it is useful to know this technique. The main benefit of this method is that you can construct method calls during runtime using information that you only get while your app is running.

Read more

Physics 101 – UIKit app with Box2D for Gravity

Personally I was most at the edge of my seat at the “Voices that Matters Conference” in Seattle when Rod Strougo showed us how to make a physics-enabled game with Cocos2D and Box2D in under an hour. It really was as sexy as he sounds. Eros did what every good TV-cook would do, he had most things already prepared. On the flight home I wanted to see if I could just take the physics part (without Cocos2D) and make a UIKit app with it.

The goal of this experiment was to have a UIView with multiple square subviews of different sizes that would start falling as soon as the app starts. The first tricky part is how to add the latest version of the Box2D physics engine to your iPhone project. Then we need to mediate between the different units and coordinate systems of UIKit and Box2D. Finally when we got it all running, we also want to add  the current gravity vector to affect the boxes.

Read more

Back (Almost)

My trip to Seattle was great, some of the talks on the conference where indeed worth my while and my host Kevin proved to be extremely hospitable. Something that did almost shock me in the beginning was being approached by half a dozen people individually who came to me to thank me for my blog. I don’t see myself as a celebrity, but I guess with 500 people stumbling upon your online ramblings, chances are that somebody will recognize you, especially if you attend an iPhone-related conference.

These are a few of the nice people that I had the presence of mind to get a picture with after they thanked me and told me that they are reading my blog. Thank you! I appreciate your appreciation. 🙂

I did not get a chance to write anything useful since Seattle for several reasons. First I lost 2 days due to travelling back. One day was literally stolen from me because I had to travel back to Vienna to deal with the aftermath of a break-in into my jumpbase there. The following two days where a blur, I only faintly remember buying a parasol for the deck that our father-in-law built for us while I was away.

Most of the day yesterday I spent with writing invoices for the iPads I brought home for 3 colleagues and rewriting DTAboutViewController to be allow for server-side updating of any plist. And now it’s already weekend, the only useful thing I could do was write a lengthy post for my German personal blog and this one article here.

Please be patient with me while I still try to get back on firm ground. On the plane from Seattle I managed to put Box2D into a UIKit app to have buttons be “physical”. The recipe for this will come soon.