Our DNA is written in Objective-C

NSURLConnection with Self-Signed Certificates

A year ago I touched upon the question as to how you can prevent NSURLConnection from aborting a HTTPS GET if the certificate is invalid. At that time it seemed like the only method available was a forbidden one: allowsAnyHTTPSCertificateForHost. It’s undocumented, works, but gets your app rejected if Apple finds it when scanning your symbols.

But what should people do who don’t want to shell out hundreds of dollars for a trusted HTTPS certificate just so that they can reap the benefit of encrypting their web traffic and possibly hide user login data from prying eyes? The alternative to those commercial certificates is to produce a Self-Signed one and install it on your web server.

In this article I will demonstrate how to properly and officially deal with self-signed certificates via NSUrlConnection. It just so happens that I have a *.cocoanetics.com on my website, primarily used for protecting SVN communication. If you go to https://www.cocoanetics.com you will see it in this dialog:

Since a Self-Signed certificate does not have a trusted root the standard is to ask the user if he wants to trust the web site temporarily, permanently or not at all. The reason being that encryption only makes sense if you know that the recipient is who he says he is. Any other site can also produce a *.cocoanetics.com certificate for their IP address. Root Certification Authorities (CA) provide security that only a certain IP address can be the holder of a domain name. This is why you see the trust of the certificate be dependent on the trust in the certificate of the CA.

But if you are calling web services of your own you can forego this mechanism. In this article I am documenting how.

Read more

Wooden Stands for iPad and iPhone

A few days ago I mentioned to my father-in-law Alois (who happens to be a passionate wood tinkerer) that it would be nice to have something to prop up an iPad for watching movies or playing poker. A quick search yielded one at Wired, a website woodenipadstands.com and the one that Matt Legend Gemmell had recomended: WoodPad

A mere four days later he presented these prototypes to us. Ingenious!

You can see that it works well in portrait and landscape and the iPad stand has two angles at which you can use them, 15 and 25 Degrees. To make it stand even firmer he extended to pieces at the base, so it sits rock-solid on your table. The 15 Degrees also work very well with the picture frame mode which does support landscape as well.

Read more

Transfer of Subversion Repositories

You might have noticed that your SVN access to components repositories does not work any more. As of today our old Subversion server has been turned off.

It has served me well, but it was a VisualSVN on top of a virtual Windows NET and thus somewhat a pain to maintain. The new hardware is a dedicated machine with CentOS and proper backup procedures. Previously I had to rely on some file-based backup scheme, now the are regularly saving SVN backups to a second server. Having a quad-CPU dedicated server with 750 GB RAID HDD gives us way more room to grow than we previously had on a 7 GB HDD virtual Windows server.

If you are a customer of one or more of our components then look for an e-mail informing you about new access details.

Cocoanetics Component Charts

In order to be able to send out these mails I had to go through my invoices and compile a list of customers for each component. In spirit of reusability of data let me show you how many sales I’ve had per component.

Read more

glif duels two other iPhone 4 Tripod Mounts

A while back I reviewed the only two tripod mounts I could find to fit my iPhone 4 and to this date its one of the most searched for articles on this blog. So its only fitting that I would also review the glif as soon as it became available. The two previous contenders for the crown of iPhone 4 Tripod Mounts were the Mosy Mount and the U+G4 Holder. There I preferred the latter because of how snug the holder fit my iPhone4 and because of the engineering effort that went into it.

You might remember reading how the two inventors of the GLIF wrote their own success story on Kickstarter. Originally they where shooting for $15,000 but with the help of some friendly linking they soon went past the $100,000 mark. When backing the project you had several options. One of the regular options would get you one glif as soon as mass production would start. I opted for the $50 variant where I would also receive a pre-release glif so that I could review it before everyone else. For a while I was tempted to go for the VIP option which would have gotten me a dinner with the guys, but being in Europe made this impossible.

The Glif

When you first see the Glif you might think that “there’s something missing”, it is that simple. Holders before it would encompass or grab the iPhone 4 in some way to prevent it from obeying gravity. Here is the first major difference. The glif only gribs as much of the iPhone 4 as is absolutely necessary. The material has a somewhat intentional roughness without which the iPhone would simply slide out. But because of the friction and precision molding that much material is all it takes to firmly secure the iPhone in place. Theoretically even upside down, but I would not dare doing that without some extra tape. The first few times it would hold upside-down, but I suspect that insertion of the iPhone flattens the structure of the material slightly over time which would reduce the friction to a point where the iPhone 4 would fall out. Now the material of the final production Glifs might be somewhat different, but generally it would not be wise to risk you iPhone just to boast to your friends: “weeee! upside down!”

Read more

Draggable Buttons and Labels

luckysmiles asks:

Pls anyone help me…how to move controls(like button,label.. ) from one place to another using touch events in iphone..

There are 3 possibilities nowadays on how to enable items – that is UIViews and UIControls – to be draggable.

  • override touchesMoved
  • add a target/selector for dragging control events
  • add a pan gesture recognizer

All those are variations on essentially the same thing: the iOS delivers touches to your app and you have more or less intelligent plumbing to calculate a moving vector. Then you apply this delta to either the frame of the thing to be moved or, more intelligently change the item’s center property.

When I started building a sample I wanted to create a UIButton subclass with the added draggability and have this button be instantiated from a XIB. Now it turns out that you can only create custom buttons like this, not rounded rect buttons like you usually do. The reason for this being that the regular initWithFrame or initWithCoder for a subclassed UIButton would need to instead create a UIRoundedRectButton (private Apple class) to look like that.
Read more

We Moved!

It’s been quite some time in the making and it was the main reason for my lack of updates: Moving. For the longest time this blog was hosted on a virtual Windows server, but I finally had the guts to move to a dedicated Linux box…. and ditch Windows which I was at it.

In the past I had all my content under drobnik.com which made me somewhat unhappy because the analytics would always be a mixture of traffic going to my German-language personal blog and my English-language iPhone-Development blog. Another drawback was that I had to have a “disambiguation page” under the domain root directing people to any of the sub-sites. Yuck.

Now these are the sites hosted on the new server:

I spent most of the day today – not coding on iWoman 2.0 as I would have liked to – but working with my Linux guru to get the final kinks out of of this to be ready to call the move. A bit of URL hacking via a search&replace plugin, some manual file copying, plugin updating, URL rewriting/redirecting, claiming the sites in Google Webmaster Tools and submitting sitemaps and lots of other itsy-bitsies.

Well, that should have been it. Now that this blog again stands on terra firma I can resume writing the Q&A and recipe articles that people love to read on this blog.

UPDATE: The old server can still be reached via drobnik.net. I also am moving and consolidating my Subversion repositories on the new server. Until then you can simple substitude .net instead of .com in the repository URLs. For example: https://www.drobnik.net:8443/svn/DTBannerManager/ – you will have to re-accept the self-signed certificate.

GeoCorder 1.2.1

The last major update/polish of GeoCorder just got approved only for me to find that I had forgotten to update the iTunes icon as well. Unfortunately you cannot do so any more once the app is published.

Oh well, I also still had my old twitter name dr_touch in the about dialog. So I submitted a quick update to fix these two things. Just maybe users will notice that I update my apps as often as I can and download more copies.

GeoCorder and GeoCorder [FREE] are available on the app store.

GeoCorder 1.2.0

On my recent trip to the USA I put the finishing touches on the next big update to GeoCorder. And today (while recuperating from a bit of a cold) I finished up with some 3.x compatibility issues and integration with the latest versions of DTShop and DTBannerManager.

This version became necessary because I wanted to fix a slight problem one special customer was having with the new tracking function. The tracker would disable if you didn’t have internet connectivity, say during a phone call. Another user who is into ballooning asked for a method to better filter the path to prevent the jumping around that occurs when CoreLocation switches to cell-tower locating due to signal degradation.


  • NEW: Fully redesigned artwork for Retina display
  • NEW: Map View now displays path of currently recording track
  • NEW: KML supported for exporting
  • NEW: new filter option to eliminiate implausible track points
  • NEW in free version: Option to remove ads via In-App purchase
  • FIXED: Default Recording Settings not showing on Settings View
  • FIXED: speed would not be inserted in called tracking URL
  • FIXED: tracking ping would be disabled if Internet connection was lost

While at it, I needed a testbed for the new option of DTBannerManager to allow the user to purchase removal of the Ads, which can now come from iAd, MobFox or AdMob.

Finally, I added KML as export option because this can be readily used by FTLocationSimulator to simulate movement in iPhone simulator.

KML uses so-called line strings which contain way less information than GPX tracks. They only have coordinates and altitude, no timestamps. KML was designed to represent a recorded movement through space but rather static three-dimensional lines in Google Earth.

There IS a way to represent movement through time in KML as well, but it is extremely verbose as you can see from the whale example in Google’s KML documentation. It works by creating a place mark for each track point which is very ugly. I’m only going to implement that if it turns out to be “absolutely necessary” for a specific use case.

Therefore this version of GeoCorder has one “known issue”: KML cannot be used for GeoTagging because of the missing time information. For geotagging you have to stick with the GPX format.

The update is now with Apple and should be approved in a week or so.


Do you know any facts? Like what you did before getting into iOS development? Or are you possibly looking for facts? Those facts that make blog articles much more interesting?

In this case, let me introduce you to the Cocoapedia. The name should right away invoke two associations: Cocoa, as in Apple’s API we use for developing for Mac and iOS devices. -pedia as in Encyclopedia or Wikipedia. As it should be with any self-respecting Wiki I have written up the history of Cocoapedia on its article on itself.

It’s actually the second time already that we’re launching this, the first time was a complete and utter failure. I had thought that it would smart to make it invitation-only to be able to regulate quality. But this actually prevented any kind of spontaneous growth that makes sites like Wikipedia great. So I’ve abolished these restrictions, everybody can now edit Cocoapedia and they should!

Now, don’t get me wrong, Cocoapedia is not supposed to replace any blog, forum or Q&A site like StackOverflow. Also it should not become a dumb link collection.

Have you ever wondered why some topics are on Wikipedia and why some are not? In May 2008 I wanted to know and added an entry for myself, which promptly got removed again stating that it would not be relevant for addition. From which I learned that relevance is something quite subjective and not even Wikipedia’s set of rules can objectify this dilemma.

We Cocoa developers live in our own universe which has different kinds of rules than mighty Wikipedia. To give a prominent example: Aaron Hillegass is on Wikipedia, while Erica Sadun is not, even though the latter was written dozens of books. Now, unless you are a big fan of Aarons, you probably would agree that this omission is odd. Erica has done much more for us developers but apparently has not hired an experienced Wiki-Writer to add an article for her that would pass under the stern eye of the Wikipedian.

Cocoapedia offers a remedy.

Here the idea is that all facts, events, conferences, apps, components and people connected in the least with Cocoa development have a place to go down in history. Though bear in mind that it is facts that makes a Wiki great. I don’t want to read self-glorfying hymns. I DO want to read a bit of biography and – if any – factual accomplishments, preferably with a footnote that proves them.

Over time Cocoapedia has the chance to grow into a compendium that bloggers would consult to fact-check articles on specific people. There are often disparate bits of “About” spread over developers online sites, blogs, twitter streams and Facebook pages. If you want people to know who YOU are, then you need to provide them with a concise entry.

Making an entry is very easy, I made a tutorial video showing how you can quickly start a new article which you would then fill with some facts about the topic of the article. I randomly chose Gleb Dolgich from my twitter followers who did not mind me creating an entry for him.

Don’t forget that everybody is an editor, so you never truly “own” a page on Cocoapedia. We’ve already had a bit of vandalism, but that’s easy to remove by the undo function. For extreme cases it’s possible to lock pages for a while but experience on Wikipedia has shown that in digital media, where Vandalism can be easily removed, it is generally very short lived. It’s simply less work to revert an article to a good state than it is to vandalize it.

You can look at any page’s source by going to the Edit mode. You most quickly learn Wiki-Editing by copying pieces of such code to your own articles. Consider the article about yourself your first exercise. Then once you have mastered that create references and articles for items related to you. For example if you have a partner for some of your apps, then just enclose his name with double square brackets. This will make it an intra-Wiki link which allows to create a new article if you follow it.

Finally, I request of you that you pass on this information of what need Cocoapedia is trying to fill with the help of an army of contributors. See you inside!

iCatalog.framework brings Digital Catalogs to Life on iPad

Somehow I was restless this night. When I checked my e-mail I see the reason why. My fine tuned app store antenna has been tingling as it usually does before something great happens on the app store.

There was a joyous e-mail by my US partner on the biggest project I had done in my iOS carreer so far:

All four RedCats iCatalog Apps have been approved by Apple and are now live on App Store.
Thanks for all the effort you’ve put, and continue to put, toward making this the best possible product.

The whole thing started when I got contacted on May 30th by Octavio Cifuentes at International Color Services asking for an “App Development Quote Request”. ICS specializes in digital pre-press services for top-brand retailers and cataloguers. They where looking for a contractor to do an app for them. To put it in layman’s terms, ICS is getting PDFs from catalog companies and they make sure that the colors match the clothes that are being sold. So they wanted to have a product to offer to their customers to take this PDF and make it into a digital edition for an extra free.

The Start of a Beautiful Partnership

At that time I was thinking about doing a magazine/catalog framework loosely based on the Wired-App. If you remember I reported on how Wired is saving all pages as PNG files and using an XML file to create the structure for the magazine. They where shooting over the target with that because they used full size PNGs for both orientations making one edition around 500 MB including videos. But the general way of doing it intrigued me.

When I responded to ICS’s request (after having done the usual NDA dance) I gave them three options:

  • you can become a software company and hire somebody to work on this (not me)
  • or you can outsource it to some eastern Europe or Asian country. But then you’ll need an experienced project manager to keep taps on your cheap labor. (not me)
  • or you can partner with me. I retain full ownership of what I create, but you have the exclusive rights to sell apps based on the framework I’ll be creating

At first they where hesitant, but the more they thought about it, the more they realized that only the third option would give them what they wanted. I argued that if you let your partner retain a stake in the project the outcome will be dramatically different than if it’s just a job where you bill your hours. And naturally ICS did not want to turn themselves into a software developer.

I met with ICS’s CEO James Kearns in Milano, Italy, and there we shook hands on the deal. He’s an amazing person to deal with, a gentleman as he is a scholar. What I liked especially was that he offered to pay for my development expenses because I needed something to live off from while developing the framework.


A lot of experimentation was necessary initially, especially on how to render PDFs. The challenge there was twofold: 1) you could not render the PDFs directly because of the bad drawing performance that the iPad has and 2) because there where thin lines all around those PDFs due to some print-specific features that are being used. These lines are hairlines and disappear in printing, but they show up as 1 pixel lines in the PDFs. So we chose to pre-render the PDFs at a multiple of the resolution which makes the pages super-crisp and the hairlines disappear.

Much work also went into working around performance limitations of the iPad. In my tests the decompressing and drawing of a full screen image would take up to 300 ms which would cause enormous jerkiness. Only 3 frames per second is much less than the ideal 60 frames. I solved this dilemma by moving the page drawing onto a background thread with the help of CATiledLayer. But not without opening a bug report at Apple to complain about the bad image performance. Now scrolling on the iCatalog apps is smooth as button, only if you scroll very quickly you see pages pop up after a brief delay. But this is the best you can get without resorting to OpenGL.

Octavio was my counterpart at ICS and he did all the designing and stuff while I was able to concentrate on the programming of all the features. It’s not immediately obvious at first glance but there is a great deal of small things that we had to polish, polish and polish. I could not have done without a person at the creative helm. I don’t do design. I had some ideas about usability and experience in what would work in an app.  But I don’t like to push pixels around in Photoshop. So OC and me where the perfect team for this task.

Catalog vendors are particular when it comes to so called “Spreads”. If you open the catalog you have two pages next to each other and you might have something that is continued over both pages. So I had to create a way to animated smoothly between the portrait and landscape mode retaining info on which page you where. Say you start in portrait mode and rotate the page you where at was a right page. If you then rotate back you end up on the same page. This is one of the many details that make or break a digital catalog experience. And one kind of thing that you as a developer don’t think about, but need an experienced guy like OC to tell you.

Another thing that I am particularly proud of is the scripting engine that is the heart of all catalogs. Up until the minute that the apps got approved I was worrying a bit that Apple might see this as a rejection reason and I formulated in my head a response. All the interactions in the catalog are written as Objective-C statements that at runtime are converted to NSInvocations with the appropriate parameters filled in. So it’s not a real interpreted language or scripting engine per se, but more like a single statement parser. But it works great. Because of this I’m able to quickly add any new feature. All I need to do is to write the method to execute and then this becomes immediately available for use in all iCatalogs.

It’s only natural that iCatalog also supports video and audio playback but those you best see for yourself in the Jessica London iCatalog app.

Online Integration

All iCatalogs work great if you are not connected to the Internet. There are however two things that you might want to get connected for:

  1. Sharing individual products or your entire Wish List on social networks
  2. Purchasing

I knew from my experience that Apple would reject all apps that don’t work well if you are in airplane mode. That’s why I took extra care to fail gracefully if the internet connection drops out. Reachability 2.0 to the rescue!

Online Purchase integration is different for each catalog client. For the initial batch we chose to just integrate it with the existing online shopping bag. All your wish list and shopping bag items are kept on your iPad until you tap the checkout button. When you do – and if you have Internet – your choices are transferred to the online site and there you fill in your address and credit card info to complete the purchase. Down the road we want to get a proper XML API to transfer the shopping bag, but for now this method works great.

I saved much time when implementing the social sharing functions by not coding them myself but instead using ShareKit. This enables us to share items through a multitude of social media sites right out of the box. Fortunately the most pressing bugs had been fixed just in time for this release.

Edit This

The interactive areas where the second source of pride. I called them “Hot Zones” and they are basically rectangles you draw on the catalog page with the editor. Then you specify different actions for single tap, double tap or automatic execution on page showing. You can assign an icon, a sound and many other options to fully customize what such a hot zone would do. For example the feature “Swatch Match” is constructed such that you have multiple variants of a catalog page with different colors of a product which you can flip through by tapping the button.

Speaking of the Editor. Initially we considered doing an app to do the editing of catalogs. But since I never did a Mac app before I incorporated all the editing functions into the iCatalog project itself. This way OC can immediately check that what he sees is what he gets when putting together a new catalog. By running the editor version in iPad Simulator he gets the best of both worlds: the look and feel of the catalog on the iPad as well as all the benefits of the desktop like access to the files and multi-core rendering performance.

I might still do an editor down the road if the framework has stayed stable for some time, but until this occurs having an in-app editor is the best solution. This edit mode is easily disabled when building an app for a client by means of making a simple change in the PCH file.

How To Get Your Own iCatalog

I know that some people out there might be tempted to trying to do something similar. Maybe you have been contacted by somebody with a catalog or their agency and asked for a quote. While it has been an extremely rewarding experience for myself I would not recommend for anybody to undertake it unless the company looking for a digital catalog is prepared to pay at least 3 months worth of development for it. Not to speak of the ongoing work that is necessary to polish it and add new features as they become necessary.

The alternative to spending thousands of dollars is to license the iCatalog.framework. As I mentioned previously ICS is my international commercial partner for it. You can contact Octavio Cifuentes to schedule a demo and explore how ICS can help convert your catalogs into a compelling iPad experience. At any case I recomend to you check out any or all of the free iCatalog apps that are already in the store.

Update: Here’s a demonstration of the iCatalog framework and a peak behind the scenes on how such a digital catalog is made.