OmniGraffle is SO cool!

I’ve been building a simple little app to play FLV files on the Mac and I should be releasing it some time over this weekend. I needed to make some icons and I threw them together in OmniGraffle Pro. Go check out for more details. 
I’ve used it a few times for this sort of thing. Here’s an example of what som
ebody who has no graphic design skills can accomplish very quickly 😉 
I’m pretty happy with it 🙂 It looks pretty good shrunk down to 128×128 and the alpha channel comes out when I export is as a PNG 🙂 

Blog spam and other stuff

I finally got around to cleaning up the spam on this blog. 
Unfortunately it looks like I zapped a couple of legitimate comments in the process however 😉 
I’ve been really busy of late working and looking after the monster baby (who just recently turned 1 year old). 
On the train to and from work I’ve been building a simple little database tool for myself. I’ll probably be releasing an alpha some time soon (although when soon is I could not say exactly 😉 ) 
It’s a Objective-C cocoa app that connects to pretty much any database that has a JDBC driver. 
It features syntax hilighting, simple code completion for SQL syntax (and I’m working on making it do code completion for database objects) and the big feature for me is tabbed based query results along with tabbed documents. It’s already pretty usable, although I still jump back to CocoaMysql on occasion for some things. If you’re feeling brave and want to give it a try feel free to email me at

Cocoa bindings

I have to say that Cocoa bindings are one of the coolest things to some to Cocoa in a long time. 
It takes a bit of getting used to however, and the documentation isn’t the greatest. One of the things that had me stumped for a bit was how to have a button
s enabled flag depend on more than one edit field having a value. There was only one Enabled binding. It seems that Interface Build adds more Enabled bindings as you create them. So you add an Enabled binding, and all of a sudden in the bindings tab appears Enabled2. Add another one and what do you know Enabled3 magically comes into existence 🙂 
I spent a little while looking to see if there was some way of doing something like Enabled = IsNotNull(field1) and IsNotNull(field2) and IsNotNull(field3), when all I had to do was just add them in. 
It’s nice when the tools are smart like this, although it would also be nice if there was some documentation that said something like this would happen. I guess I should have know it would do that since it makes sense for it to do so. One of the nice things about Apple software is that it tends to just work (most of the time). 

The cocoa rendering system is really nice

For a secret project I’m currently working on I needed to make a NSTextView that resized its contents so that it was always fully visible regardless of how many lines of text were in there. Coding something like that under Windows would have been pretty awful (especially since the text needs to still be editable), but cocoa made it a snap. Just make sure that the ratio of the control bounds and the parent controls frame is correct every time the text changes 🙂 The more I use cocoa, the more I want to use it, and the less I want to go back to other systems. 
From what I understand the Microsoft .Net stuff would allow a similar approach, and the Java swing libraries would definitely allow it 

Accessing the string and attribute data in a NSTextView

NSTextView stores its data in a NSTextStorage object. NSTextStorage descends from NSMutableAttributed string, so that gives us a clue. 
The easiest thing to do is to make a category on the NSAttributedString class to do whatever it is you want containing something like the following. 
    NSRange range; 
int i; 
int L = [self length]; 
    i =
while(i<L) { 
// get all the attributes we are interested in 
        NSDictionary* attributes = [
self attributesAtIndex: i effectiveRange: &range]; 
        NSAttributedString* attPart = [
self attributedSubstringFromRange: range]; 
        NSString* part = [attPart string]; 
        NSFont* font = [attributes objectForKey: NSFontAttributeName]; 
        NSColor* color = [attributes objectForKey:
        NSParagraphStyle* paraStyle = [attributes objectForKey: NSParagraphStyleAttributeName]; 
        NSShadow* shadow = [attributes objectForKey: NSShadowAttributeName]; 
        NSURL* link = [attributes objectForKey: NSLinkAttributeName]; 
        NSTextAttachment* attachment = [attributes objectForKey: NSAttachmentAttributeName]; 
// process your attributed string pieces here 
        i = range.location+range.length; 

Colourized entries

    I went to all the trouble of adding code to allow for different fonts and colours and such. I tested it on my local machine against WordPress 1.5x and it all worked perfectly. Then I tried to make a post here where I’m running WordPress 2.0 and found that it stripped out all the lovely colours. 
    After a bit of poking about on the net I found that this is a bug in the 2.0 WordPress code base and as since been fixed in the 2.0.1 release. So after a quick update of the code…. Here we are. 
// BlogAPI.h 
// BlogThing 
// Created by Daniel Parnell on 28/01/06. 
// Copyright 2006 Automagic Software. All rights reserved. 
#import <Cocoa/Cocoa.h> 
@interface BlogAPI : NSObject
NSURL* url; 
NSString* username; 
NSString* password; 

+ (BlogAPI*)
blogAPIWithURL:(NSURL*)aURL username:(NSString*)aUsername andPassword:(NSString*)aPassword; 
+ (
NSString*) describeBlogError:(NSDictionary*)errorInfo; 
– (
id) initWithURL:(NSURL*)aURL username:(NSString*)aUsername andPassword:(NSString*)aPassword; 
– (
void) setUsername:(NSString*)aUsername; 
– (
NSString*) username
– (
void) setPassword:(NSString*)aPassword; 
– (
NSString*) password
– (
void) setURL: (NSURL*)aURL
– (
– (
NSArray*) getCategoryList
– (
int) newPost: (NSString*)aTitle withBody: (NSString*)aBody andDateTime:(NSDate*) aDateTime shouldPublish:(BOOL)flag; 
– (
BOOL) setCategories: (NSArray*)theCategories forPost: (int)aPostId
– (
NSString*) upload: (NSData*)data withName: (NSString*)name