Apple Museum

After a rejig of my office, there is finally room for the Apple museum. More pieces to come!

Your eyes don't deceive you, that is a 5 1/4 inch drive - the processor direct slot has an Apple // card in it (which was designed for the LC, which my parents bought it with, but it works great in the Colour Classic).

Apple Push Notifications Talk—Screen/Audio recording now available

Thanks again to the guys at the Apple University Consortium for inviting me to speak at /dev/world 2010. The screen/audio recordings are now available. I have linked to them (and the rest of the /dev/world presentations) on my APNS talks page:

Quickly add PDFs to iTunes/iBooks

Being able to transfer PDFs to iBooks on your iPad and iPhone is really handy. But sometimes it's a pain to either make or track down an actual PDF file. Here's how to do it painlessly.

For any non-PDF document, you can print to PDF and open it in iTunes. But you can collapse that with this neat tip from MacWorld.

If you want to quickly add a document or a web page to your 'Books' collection in iTunes, all you need to do is to create an alias of iTunes and drag it to ~/Library/PDF Services. Now, when you're browsing the web or viewing documents and you decide that you want to read them later on a portable Apple device just hit Print, click the PDF button on the bottom left corner of the window and choose iTunes. iTunes will launch and receive the PDF. Next, sync your device and you're ready to go.Source

But what about when you've got a PDF already open in Preview (say you clicked a PDF download link)? Sure you could save to desktop, drag into iTunes, delete it. Or find 18e3764.pdf in your download folder etc. But if you're any kind of Mac commandline nerd, you will already have DTerm installed (if you don't - do yourself a favour and go check it out).

So you have a PDF open in Preview (or any other PDF app) - just hit your DTerm shortcut key combo (mine is Command-Shift-Enter), then type open -a iTunes then hit Command-Shift-V. (this pastes the path of the current window's file into the DTerm commandline) and hit Enter.

Now your PDF is in iTunes, already highlighted ready for you to change the title if needed.

Debugging release/autorelease issues in Cocoa

So your code crashes with an EXC_BAD_ACCESS in objc_msgSend and there
is *none* of your own code in the stack trace. Bummer. Since all we
know from objc_msgSend is that it's trying to call a method on an
object. Since we got EXC_BAD_ACCESS you can bet your bottom dollar
that it's attempting to call a method on a freed pointer, so there's
no obvious way of finding out what the object was. We can, though,
easily find the method. Read Greg Parker's excellent post So you crashed in objc_msgSend(). For the iPhone
simulator on my Mac I need to do this at the gdb prompt to decode the
eax register:

(gdb) x/s $ecx
0x980530c4: "release"

you can see that the selector in the second argument is "release". Now
we're getting somewhere, we know an already freed object is trying to
be released. Since there is none of our code in the stack trace it's a
fair bet that it's happening when the autorelease pool is releasing.

I've found this is not always reliable (logs from the above builtin debug options showed that the over-release was on an NSCFDate object, when in fact it was an NSNumber). Sometimes you also just want to trace through exactly what is happening with your retain/release/autorelease cycles. That's what we're about to achieve here.

Ok, so you have a unit test that replicates this problem right? I use
the excellent GHUnit by Gabriel Handford. If not
you'll have to play around a bit to narrow down your problem code. In my case, I wanted to confirm that a particular unit test was
failing during the autorelease pool release. Best way is to wrap the
offending code in a new autorelease pool. Then it will be freed inside
your code, which you will see in the stack trace, and confirm you have
found the reason. My unit test now looks like:

(Note that the code examples, embedded in github gists, are not showing up in my RSS feed. I'll fix that later, but for now please read the original post)

Now when I fail with EXC_BAD_ACCESS my stack trace looks like this:

Where line 91 of CJTestCJCard.m is the [pool release] call above. So
something is being added to the autorelease pool, and is *also* being
fully released, or maybe it's being added to the pool more times than
it is being retained. There doesn't seem to be a way to interrogate the
contents of the autorelease pool (which is a shame) but we log some
really useful info by overriding a few methods, like NSObject's
release and autorelease methods, so we can see when things are being
added to the pool and when things are being released. This is some
funky stuff, but since we're only doing it in our unit test class, not
code we're going to release you can sleep soundly at night. Here's how
I effected logging in release and autorelease.

Add this to the top of your unit test class, before your current @implementation:

Now in your unit test class @implementation, you can use the
setupClass method to effect the method implementation switcharoo:

Now your log will be filled with log lines like:

This can help when tracking down tricky releasing bugs. Note that not
all classes seem to comply. For instance I see plenty of log lines for
NSCFString, but never any release lines. I assume that NSCFString
release implementation is a bit different since it's a toll free bridged object -
getting that to log is an exercise left for the reader!

CocoaHeads Sydney - May 7th 2009

CocoaHeads Sydney is steaming along with our fourth monthly meeting on the trot this Thursday.

Last month at CocoaHeads Sydney I gave a lightning talk showing how to add Apple IR support to your Cocoa app. I have uploaded the slides to the files section of the google group.
In the presentation I also showed how I used the LaTeX beamer class to make pdf slides, and I used the open source SplitShow application to give the presentation (using my Apple IR support of course!) You can get SplitShow from the google code project but you'll have to build from the trunk to get the IR support which has not yet been included in a release.

We also had Ben Hill show us the impressive prototype of an OpenGL iPhone game he put together using cocos2d.

This month our very own Jude Sutton will be giving us a presentation on the Authorisation Services and related APIs.

CocoaHeads Sydney - March 5th 2009

I'm excited our Sydney CocoaHeads meetup next week, looking forward to expanding on our great start of 20 odd people (that is 20 or so people, although many of us may also be odd...).

André's talk last month was an interesting delve into Objective-C internals and creative ways to make use of that knowledge. (slides).

This month I am pleased to announce that Nathan Day, who was in our meeting last month, will be presenting something that instead saves you from having to know about some of the nastier internals of the Cocoa framework&#8212his extensive collection of public frameworks.

Nathan was guest speaker at Brisbane CocoaHeads last Thursday and has agreed to make a repeat performance for us.

The location will again be UTS although the room may be different as the semester is approaching, stay tuned for details.

There are details about subscribing to the google calendar on a page in our group: http://is.gd/kEtW

Or you can use this link to add the March meeting to your own calendar: http://is.gd/kEud

I'll update the calendar meeting with the room details etc. when I have them and will also email the cocoadev list etc. closer to the day. Looking forward to seeing you all there!

Native MacOS Umbrello in KDE4

One of the consistently popular pages on this website is my blog entry about building Umbrello on MacOS. Umbrello is the KDE UML modelling program. UML modelling programs are mostly surprisingly rubbish, so Umbrello being not rubbish is one of the better ones and it's open source to boot.

It has, though, been tough to build on MacOS even just under X11 (as witnessed by the long list of comments on my earlier blog with various configure recipies). KDE4 promises to resolve that with the native MacOS Qt support allowing Mac native applications.

The Mac KDE project has beta downloads of the (nearly) full KDE environment for Mac. All the bits you need are at http://mac.kde.org/ but note they are hosted on an ftp server that allows you to only download one file at a time, so let one finish before you start the next. No compilation or commandline trickery needed - just installing normal MacOS packages.

After installing the various bits you will find a KDE4 folder in your Applications folder. Here's Umbrello running on my Mac:

There are a few oddities - I could maximise the window, but not drag the window size to anything other than the original or the maximum, but otherwise it seems quite solid.

25 years of Macintosh--illustrated timeline

I have owned or used every item in this picture except for the Lisa and Macintosh Portable (though I have seen both of them at one stage). I even have the eWorld disks still and DB has a copy of the (pictured) MacWorld edition 1.

MacBook (Nvidia) video flicker or "tearing" on scroll/video

My new MacBook has an annoying issue. Especially after sleep, the GPU goes a bit mental and has issues with high bandwidth data - eg. fast scrolling or video (eg. YouTube) playback. It seems basically that it just can't ship the bits to the display fast enough because if you scroll slow enough there is no flickering.

After sleep/wake it is really bad&#8212;to the point that it distracts. It is in multiple applications (Safari, Xcode) so I assume it is a video driver issue. Some 'net reports for MacBook Pro users say that it is not an issue if you choose the faster GPU on that laptop (the GeForce 9600M GT) suggesting that it is a driver/chipset issue with the Nvidia GeForce 9400M.

I found one tip that improved the situation, when you get the problem you can force some sort of vido reset by pressing Control-Shift-Eject (you might need to hit a key or wiggle the mouse to wake the screen back up again).

It doesn't completely eliminate it, but at least in normal non-video use you don't notice it so much.

Since a reset of some sort improves it, I assume it is something to do with the way the chipset is brought up after sleep so hopefully either a driver or firmware update should be able to either resolve it or if it is a chipset issue at least work around it.

CocoaHeads Sydney - February 5th 2009

After the very successful, and inaugural, Christmas beers event held by Sydney CocoaHeads in December, our first meetup for 2009 will occur on Thrusday February 5th.

What is CocoaHeads?

CocoaHeads is a global collection of groups devoted to discussion of Apple Computer's Cocoa Framework for programming on MacOS X. During monthly meetings, members present on their projects and offer tutorials on various programming topics.

February, the ever interesting André Pang will be speaking. You can find more details about the Sydney meetup by joining our Google Group: Sydney CocoaHeads.

Unibody MacBook VGA = sucky

Last week I bought a new Unibody MacBook. Nice and fast, perfect size, so far so good.

Then I connected it to my venerable (but still awesome) Silicon Graphics 22" CRT monitor with the mini displayport -> VGA adapter.

I knew the maximum resolution supported via VGA was going to be 1600 x 1200 from the manual (p66) which was fine with me since that is the resolution I usually use.

What the manual and tech specs page gives no mention of is that the highest refresh frequency you can run at 1600 x 1200 over VGA is 60 Hz. That's enough flicker to drive you mental immediately (and give you a headache in about a quarter hour).

The next resolution down offered is 1400 x 1050 at 85 Hz. Plenty fast enough, but that's 450,000 less pixels. No thank you.

Thankfully, with the magic of DisplayConfigX you can change the refresh/resolution combinations MacOS X will offer you. You can't squeeze any more bandwidth than the hardware maximum, but you can make different compromises. I figured I can run 1600 x 1200 at 65 Hz (too flickery), 1536 x 1228 at 67 Hz (still too flickery) or 1472 x 1177 at 69 Hz. This last combo is just about palatable as long as I boost the brightness a little (to increase phosphor persistence) and degauss regularly.

DisplayConfigX is $12 USD, but that's easily worth the 26,2544 pixels I have reclaimed thanks to its flexibility.

Of course Apple's tech specs and docs should have provided the relevant detail. Not that that would have changed anything (other than a frustrating discovery) since to my mind the 15" laptops are just a shade too big and heavy (I am upgrading from a PowerBook 12" remember...).

Retro Mac nerd alert

Kath and I both had food poisening on the weekend (I'll spare you the details) so I've been couch bound for a few days. What better iq-free way to kill some time than by geeking out with mac emulators. After numerous games of Shufflepuck Cafe, Glider, Prince of Persia etc. I stumbled across this insane website:

Installing avrdude via MacPorts

avrdude is a program that you use to download compiled software to the (excellent) Atmel AVR line of microprocessors.

Trying to install the current avrdude via MacPorts can hit a snag though, because there is a flex source file (lexer.l) which won't compile with the version of flex that MacPorts installs (if you have ever installed flex via MacPorts).

The Apple supplied flex is fine, so the Portfile just needs a little addition to point the ./configure in the right direction.