Our DNA is written in Objective-C

Category Archive for ‘Recipes’ rss

Tokenize This!

I have two vendor IDs, one from my time as Individual and the newer one since I changed to a Company developer account. There might be other other reasons for having multiple vendor IDs, if you know of any, please let me know. I’m curious.

Now for this week’s update to AutoIngest for Mac I wanted to turn the plain text Vendor ID field into a token field like the Mac mail app has. Fortunately NSTokenField exists on Mac since 10.4 and today we shall explore its use.

Read more

BSA Banner

Simple Reachability + Blocks

The Reachability sample is arguable the one piece of Apple sample code that is seen in most wide use. But it is just that: a sample.

It was lacking in some regards and so a plethora of variants popped up, all with varying version numbers. But all these version numbers do is to mask the fact that these are not “official” versions of sanctioned Apple code.

Yet another problem is that people needed to start prefixing their versions of Reachability as to avoid conflicts with other people’s Reachability contained in other components.

Read more

Local CocoaPods

Today I learned that besides of using CocoaPods pod specs via the official repo, you can also use local clones of the source code as pods.

Read more

Getting Glyph Paths with DTCoreText

A client wanted to have a method for producing text that has a “cut out” effect, aka Text with “Inner Shadow”. Sort of like if you take a sheet of paper and then cut out the letters, then have light coming from up and slightly to the left so that it throws a shadow into the cut out letters.

For such a scenario you have to get a CGPath that is comprised of the glyphs that make up the text. Those are called glyphs because in some languages they are letters, but in some others they are not. Glyphs are the atomic element that any written language consists of.

Because it reasonably fits with the other work I have already done in DTCoreText I added such a method to both the classes for glyph runs as well as lines. These new methods will be released in the upcoming DTCoreText 1.5 release.

Read more

Moving from SVN to GIT

When we started with Source Code Management (SCM) – at the time – we still had a virtual Windows server running with QualityHosting.de. So a friend set up VisualSVN for us on this box. This got us started with Subversion.

A few years later I got started with git. Then I got into it a bit more with git submodules. Those were the beginnings of a beautiful friendship.

Two years later we decided that was enough of procrastrinating. Finally the time had come to switch to git for good. Read more

Localization Unit Test

It happens to the best: you add new features to an app localized in several languages. You are not the lazy type that names the NSLocalizedString key’s the same as the English-language strings. Instead you name the keys semantically, like DOWNLOAD_ALERT_MSG.

Then when it comes to shipping you send the client a note that there are some new strings and assume that he will be able to find out which are new and need to be translated. Which he would if he was using a tool like Linguan. Which he is not, because you might have forgotten to recommend it to him, or if he’s extremely unlucky then he’s a Windows user.

Read more

Apple’s ASN.1 OID Names

For the DTCertificateViewer component that I am presently working on I needed to have a list of all known OIDs. Those are the tags (Object Identifiers) that identify the meaning of information encoded in CER/DER/ASN.1 files.

For example OID means “Country Name”. I was able to glean a few dozen such identifiers from looking at a variety of certificates, but I couldn’t find a complete – and localized – list of those names anywhere online. Also Apple has registered a boatload of their own OIDs like “1.2.840.113635.” = “Apple Developer Certificate (Development)”.

Since I’m building this component for use on iOS and Mac it became clear that I needed to go straight to the horse’s mouth to get my strings. In this article I am going to explain how I got my list of OIDs, in all 30 languages that OS X is localized in.

Read more

Auto Doc

With Appledoc + Jenkins it is fabulously easy to have your documentation be automatically generated and uploaded to a documentation site. Let me give you a quick guided tour about the individual parts of our setup. The final result you can admire on our new Cocoanetics Documentation Site.

Read more

Dynamic Unit Test Cases

You probably now how to add static test cases to a SenTestingKit-based unit test. You create a subclass of SenTestCase and add instance methods with their names prefixed with “test”.

When the unit test runs it builds the test classes and then introspects each one to dynamically find all such named instance methods. Those are then executed one after the other.

Usually you get by with this technique but there might be scenarios where you would want to be able to dynamically add test methods based on some external information, like a property list. Let me show you how.

Read more

Scotty, We Need More Power!

I remember a long time ago when CPUs still had only a single core and the chip manufacturers where racing for getting the highest Gigahertz. Then some technical limit was reached they shifted their philosophy to increasing the number of CPU cores. The unfortunate side-effect of this approach is that we developers need to adapt our code to make use of these multiple cores or else our CPU-intensive code will find a bottle neck in being only able to max out one core.

Scotty, we need more power!

In a previous article I described how optimizations in genstrings2 (our Open Source replacement for genstrings) led to the re-implementation being upwards of 30 times faster than the original.

The reason of this was mostly grounded in some smart using of multiple GCD queues. In this blog post I shall explore how we can get DTCoreText to also make use of all available CPU cores.

Read more