Pioneering Software

Innovation, quality, care.

Out Parameters When ARCing

| Comments

Be careful when assigning values to out-parameters when Automatic Reference Counting. Ensure that there is no auto-release pool in-between where you assign the parameter and where you use the out-parameter. Easily overlooked when using C blocks, especially when passing blocks to Cocoa APIs which can enclose your handler within an auto-release pool without you realising it.

Apple-Generic Versioning

| Comments

Getting to grips with Apple’s “generic versioning” can be slightly painful, at first. Application and framework bundles typically have numerous differing version numbers: marketing version, build version; dynamic library current version, dynamic library compatibility version. Exactly how should you reconcile these version numbers? This article explores the questions and offers some answers.

Developing a Project as an OS X Framework and iOS Static Library at the Same Time

| Comments

You want to develop a framework for OS X and iOS at the same time!

This is not a strange thing since OS X and iOS are substantially similar underneath: a Unix box running Cocoa. With Lion, Apple seem determined to make them even more similar. And why not?

You want both framework and library to share identical sources so that you do not need to maintain two mostly-similar sets. If there are any differences, you want to limit that only to actual differences, not just differences in the way they need compiling and linking.

There is a simple way to do it.

Gloss-Caustic Shading

| Comments

Matt Gallagher recently wrote a very useful article about drawing gloss gradients using Core Graphics. In his article, Matt describes how to reproduce the oft-seen glossy gradient effect. Thanks Matt! It’s a nice article. “Cocoa with Love” lovingly provides the working source code. This little article aims to complement Matt’s work.

I’ve also re-factored the software and packaged the result within an Objective-C class called RRGlossCausticShader. This packaging automatically adds support for key-value coding and observing. Bindings then let you easily wrap the class within a little application able to adjust the many parameters interactively.

Permutation Class

| Comments

Permutations! I’ve hit this issue quite a number of times in my life: at university, at work. It’s not unusual to encounter problems where it’s very handy to able to iterate all possible permutations of something. And catch is: standard libraries sometimes do not offer any help. The engineer is left to tackle the problem by him- or herself.

Sorting an Array by Another Array

| Comments

Suppose you want to sort an array of strings according to some prescribed order. In other words, you are given an array of strings as input, plus another array of strings describing the required ordering. The result is another array of strings equal to the first but sorted by the second.