Interface Builder bug

Interestingly, I came across a bug in Interface Builder tonight while working on a Cocoa-Java app.

I was working with a NSTableView.DataSource as a delegate object, and in the NSTableView I assigned an NSNumberFormatter to one column, and set it to display negative values as red. After I saved and tested my app I was surprised that negatives were still black! Hm. I repeated several times.

Eventually I gave up and wrote the following code to work around the situation... it isn't pretty... feel free to send me optimizations and replacement code!:

public void awakeFromNib() {
//workaround for bug in interface builder that loses the setting to make the text color red on the
//Margin column for negative values
NSMutableDictionary tmp = new NSMutableDictionary();
tmp.setObjectForKey( NSColor.redColor(), "NSColor");

//argh, and since column identifier isn't saving in interface builder either, must loop through columns
NSTableColumn marginCol = null;
NSArray cols = updatesTable.tableColumns();
for (int i=0; i<cols.count(); i++) {
if ( ((NSCell)((NSTableColumn)cols.objectAtIndex(i)).headerCell()).stringValue().compareTo("Margin") == 0 ) {
marginCol = (NSTableColumn)cols.objectAtIndex(i);

if ( marginCol != null ) {
NSNumberFormatter tmpFormat = new NSNumberFormatter();
NSCell tmpCell = marginCol.dataCell();

(yes, i look at that code again and it is ugly still... but I can fix/optimize later. I'm more concerned with getting a working app finished)


Dead iBook battery

Well, after 18 months my iBook battery is dead.

I noticed that the battery meter in my menu bar was showing a little black 'x' and the menu read 'No batteries available'. I figured "this can't be good news", frowned, and began googling.

The obvious solution is here (that the battery is just dead... buy a new one):

I did some more searching in the hope I wouldn't have to buy a new battery. I found some references to OS9 being able to charge a battery that OSX won't recognize. So I reinstalled Classic and booted up into it after resetting the PMU. Sadly, no luck. Classic would show the battery at 0% for a while, then 'X'.

I even tried a dubious hint that said to short-circuit the battery by connecting the two end connectors with some wire. Still no luck... just some pretty sparks.

So I'll be buying a new iBook battery soon. With my luck, they won't be selling them anymore and my only option will be a 17" Powerbook instead. Yeah, right.

PS. Battery also had no LEDs since the problem started. Indicating no charge... or that its little chip is completely dead.