Gloss-Caustic Shading

Posted by Pioneer! Wed, 10 Dec 2008 03:25:45 GMT

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.


Outline view, tree controller and itemForPersistentObject

Posted by Pioneer! Wed, 10 Sep 2008 12:42:56 GMT

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.


Organising view controllers, continued

Posted by Pioneer! Mon, 01 Sep 2008 21:59:24 GMT

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.


Organising view controllers

Posted by Pioneer! Fri, 29 Aug 2008 06:37:41 GMT

Understanding how individual view controllers work is one thing. Organising them is another. Applications typically deal with multiple view controllers. Views can change dynamically. Hence view controllers need dynamic capabilities.

This article presents an idea for organising view controllers within an application. Design goals include: flexibility, simplicity, convention over configuration.


View controllers

Posted by Pioneer! Tue, 26 Aug 2008 17:30:00 GMT

NSViewController. It’s an enigmatic class.

Exactly what is it? When should it be used? Apple’s documentation does not paint a clear picture. What is there to glean from its interface, implementation as well as others’ work on this subject?


Permutation class

Posted by Pioneer! Fri, 22 Aug 2008 07:22:00 GMT

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.


Factorial function in Objective-C

Posted by Pioneer! Thu, 21 Aug 2008 09:04:00 GMT

Factorial, denoted by n! and defined as the product of all positive integers less than or equal to n.


Sorting an array by another array

Posted by Pioneer! Wed, 20 Aug 2008 06:03:00 GMT

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.