Dear Lazyweb,

Please buy my handmade Tanglewood acoustic guitar and metal Chess pieces. Thank you!

Want to join me seeing Paradise Lost at the Islington Academy this evening at 19:00? I have a spare ticket to give away. Send me an email at stig@brautaset.org with your name and phone number if you’re interested. First come first serve.

So hilarious, yet so sad!

November 12, 2007

Will comments on a story in the Manchester Evening News about a lottery that has been scratched because a lot of people get confused about which number is lower: -6 or -7.

I’m in two minds about the “news”. My immediate reaction was to find it hilarious. It proves rule #1: people are stupid. But then I started to think. Nobody could really be that stupid, could they? I can’t help feeling that the story must be fabricated. Maybe it was a slow news day, so the paper cut a few corners. Or could it be that people are so eager to be in the limelight that they’re willing to come off as complete idiots to get their 15 minutes of fame?

My second reaction is depression, and a deep sadness about the state of education in UK. I knew it was bad, but it was news to me that the level of reading and numeracy is so poor here that a significant portion of grown-ups can’t even read a thermometer.

New Cocoa blog

October 17, 2007

I’ve started a new blog, Hot Chocolate, where I’ll be posting on Cocoa development. Check it out.

Desdemona 0.4.1

October 9, 2007

I’ve released a new version of Desdemona, my Reversi game. From the release note:

Fixed a nasty bug in the AI which could lead it to make strange (and terrible) moves near the end of the game. Also fixed an error in the search optimisation code that caused the AI to perform much weaker than it should be.

Given the latter fix I also took the opportunity to overhaul the difficulty levels. There was too little difference between them. The same range of levels from 1-10 is available, but they now represent a wider range of ability in the AI.

Difficulty level 1 is about the same as it was before. However, at level 10 it will now take about 22 seconds to search for a move, up from about 10 seconds previously. (Because of the bugfixes, however, the prior version would have to use about 5 minutes or more to perform as well!)

Songs of praise

October 8, 2007

More software should be released in a song.

You can now produce human-readable JSON! There is a new method that takes options to control the formatting.

The public methods were renamed to jive better with existing Cocoa conventions. The affected methods are as follows:

  • -JSONString was renamed -JSONRepresentation
  • -JSONStringFragment was renamed -JSONFragment
  • -objectFromJSON was renamed -JSONValue
  • -objectFromJSONFragment was renamed -JSONFragmentValue

See the website for up-to-date documentation.

I released version 1 a little while ago.

Will wants to know the scheme I use for Wifi network and computer network names. Though I’m not really keen on these memes, I’m not above admitting I’m feeling a bit flattered to have been tagged. So I’ve decided to dish the dirt:

  • My current wireless network is called “Icon”. It is named after an album by Paradise Lost. (Which was my first wireless network.)
  • My home machine is called Russet and my work machine Idared.

Anybody spot the link between the the computer names without googling? :)

Cocoa JSON Framework v0.1

September 23, 2007

I’m proud to release version 0.1 of my JSON framework for Cocoa! Other people have released code to work with JSON in Cocoa, but this would appear to be the first project to provide an stand-alone framework (an embedded one at that).

From the website:

This framework contains a collection of categories on existing Cocoa classes that together provide full JSON support. Importing the <JSON/JSON.h> header provides the following main methods:

-[NSArray JSONString];
-[NSDictionary JSONString];
-[NSString objectFromJSON];

Strictly speaking JSON has to have at least one top-level container (array or object/dictionary). Nulls, numbers, booleans and strings cannot be represented in strict JSON on their own. It can be quite convenient to pretend that such JSON fragments are valid JSON and the following methods will let you do so:

-[NSNull JSONStringFragment];
-[NSNumber JSONStringFragment];
-[NSString JSONStringFragment];
-[NSString objectFromJSONFragment];

Edited for clarity after original posting.

Updated: I’ve released version 0.2 now.

I released version 1 a little while ago.

Embedding Cocoa Frameworks

September 22, 2007

Cocoa has a really neat feature that allows you to embed a framework inside your application bundle. Why would you want to do this? Not all frameworks are available everywhere. Instead of forcing your users to install lots of frameworks before they can start using your app, simply bundle them inside your app.

You cannot simply embed any framework; it has to be built specifically for embedding. A framework is a dynamically linked library. These have the path they are installed at hardcoded inside them. (For security reasons, or some such; it’s damn inconvenient at any rate.) Normally these paths are of the form `/Library/Frameworks/`. For an embedded framework, however, we have to use something else. The special path `@executable_path` refers to the path of the executable inside your application bundle. You can then refer to the `Frameworks` directory in your application bundle by setting the installation path of your framework to be `@executable_path/../Frameworks`.

install_path.png

If you want to embed a framework inside another framework you’ll need the even more special `@loader_path`, which is only available in OS X 10.4 Tiger and later. I find this useful, so that’s what I used in the example above. Now add the framework to your application the way you’d add any other existing framework:

add_existing_framework.png

Add a “copy files” build phase and chose destination `Frameworks`. Drag the embedded framework you added into it.

copy_files_build_phase.png

Voilá!

Jonathan “Wolf” Rentzsch has a screencast that shows you in more detail how to embed frameworks. It is for a rather older version of Xcode than what is available now, but it is still good. The Cocoa developer guide to embedding a framework is also good.