Fri, 13 Jan 2012 09:03:00 GMT

Reference Is Not a Tree

Git is an excellent version control system. However, it does not offer much hand-holding. Linus expects you to read the documentation and understand what you are doing. How rude! One of Git’s primary features includes: making you feel less intelligent than you thought you were! It satisfies this feature quite well. This can prove especially true when dealing with submodules.


Fri, 05 Aug 2011 12:20:00 GMT

Developing a project as an OS X framework and iOS static library at the same time

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.


Thu, 09 Jun 2011 10:19:00 GMT

ASI HTTP Request Library Review

ASI has a useful class library for wrapping around the CFNetwork framework, the networking Core Foundation framework designed by Apple as a programming interface to lower-level network capabilities of iOS and OS X; CFNetwork framework is available on both platforms.


Tue, 07 Jun 2011 06:18:00 GMT

CFNetwork Framework, OS X versus iOS

A question: What are the differences, if any, between CFNetwork framework on iOS and the same framework under OS X?


Tue, 13 Jul 2010 14:52:29 GMT

Import CSV files in Rails 3

CSV is a ubiquitous importing and exporting format for tables of information conforming to row-column layout. Lines correspond to rows. On each line, commas separate values under each column; hence Comma-Separated Values. Values between commas define table-cell contents, strings or numbers. The format is relatively flexible, relatively easy for machines and even humans to read and write.

In terms of user stories, it answers the following requirement.

As a: database maintainer

I want to: import information from external files, particularly Comma-Separated Value files where rows appear on each line and columns within each row have comma delimiters

So that I can: select columns (and rows) from the CSV files and merge these to create other new pieces of information.

Question is, How do you import CSV files in Rails 3. This article attempts an answer, or at least part of an answer, enough perhaps to point you in the right direction. You can find the sources here at GitHub.


Wed, 10 Mar 2010 06:31:53 GMT

Retaining C++ Objects

C++ and Objective-C do not always mix too well, although the two languages are fully compatible.

With respect to compilation phases, alternating between C, C++, Objective-C and Objective-C++ presents no problem. You just write your software accordingly, freely mixing C, Objective-C, C++ and Objective-C++. Just make sure that the compiler knows what each translation unit contains, normally by source file extension: c for C; cc or cpp or cxx for C++; m for Objective-C; and mm for Objective-C++.

That being specified correctly, your sources compile and link without issues. Only when you start running the code side-by-side however, you might find that memory management can become something of a mishmash. Basic C++ fundamentally has no memory management; I mean nothing automatic. Asking for memory when you want it, freeing memory when you’re done with it: that is all bare C++ gives you. So you typically just roll your own, or find some more-advanced alternative such as Boehm’s garbage collector.

Wouldn’t it be nice however, if you could just simply retain, release and auto-release your C++ objects, just like you do with NSObjects? It would be very nice.

This article outlines a little “trick” for retaining C++ objects on Mac and iPhone. It takes advantage of C++ inheritance; and is simple, so no dependence on internals of CFTypeRef or NSObject. The memory cost is low; just one additional NSObject-derived object per retained C++ object. Final feature, implementation separates from interface by design. Hence you can include retaining within bodies of source without the things being retained having any knowledge of Objective-C. Translation units remain plain old C++, no additional dependencies. The implementation exists apart.

MIT-licensed code provided in full.


Fri, 05 Mar 2010 04:47:00 GMT

Gloss Caustic Shader for iPhone

Ole Begemann has done some very useful work, porting the gloss-caustic shader to iPhone OS. This work has been long overdue. Many thanks Ole!

I’ve merged Ole’s changes into my Git repo, albeit with a few modifications. This article outlines the changes to the changes.


Wed, 10 Dec 2008 03:25:45 GMT

Gloss-Caustic Shading

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.


Wed, 10 Sep 2008 14:42:56 GMT

Outline view, tree controller and itemForPersistentObject

This is the scenario: your user interface comprises an outline view and a hierarchical data model. You want the outline view to display the hierarchy and remember the expansion state automatically in preferences. Hence when the user re-runs the application, the items that were expanded are still expanded, and vice versa: what was collapsed remains so. Outline view, tree controller, hierarchical model, bindings. That’s the recipe.

According to some, storing expansion state of an outline view when used with a tree controller is not just difficult: it’s impossible! But is it? No, is the simple answer. It’s actually quite easy. In this article I introduce a new helper class called RROutlineViewExpandedItemsAutosaver! Original aren’t I? It does not involve sub-classing or access to private methods. The solution presented uses only documented interfaces and only requires a small stateless class instance for handling all outline view auto-saving technicalities. It does assume Core Data use for modelling. But you can easily adapt the technique for other data-model implementations.


Mon, 01 Sep 2008 23:59:24 GMT

Organising view controllers, continued

The last article on this subject (Organising view controllers) started looking at an example. Apple’s ViewController sample illustrates basic use of multiple view controllers. This article completes the work.

Download the source if you would rather skip ahead. Sometimes it’s easier that way. You can see the code in its full context. Snippets and extracts don’t always tell you everything you need to know.