Freelance iOS Developer, Rapidly Aging Punk

Pinline is Now Free and Open Source

Jan 30, 2015 at 10:59AM

As of yesterday I've made Pinline, my iPhone client app for Pinboard, free on the App Store with the full source available on Github.

My reason for doing this is entirely selfish – I don't want to have to think about Pinline anymore. It never sold well and it didn't get much press for the simple reason that it is not very good. I've made a number of false starts on a second version but ultimately it just isn't what I want to spend my time and attention on anymore.

Still, it would feel wasteful to just pull the plug entirely. If you liked Pinline and want to improve it or you're a newish iOS developer wanting to take a look at a medium-sized project please feel free to fork the project and poke at it. Like any good developer I tend to hate the code I wrote last week – and Pinline's last update was last year so if you see something really dumb in the code please be kind enough to assume that I know it's dumb and would do it differently today. There are warts and hacks and some of them are really ugly but I will say this in my defense: those warts shipped and those hacks worked. I'm proud Pinline got that far.


Swift Has a Preprocessor

Jan 21, 2015 at 03:21PM

I didn't know Swift had a preprocessor at all. It means you can do things like this:

#if TARGET_OS_MAC
    typealias RAImage = NSImage
    typealias RAFont = NSFont
#elseif TARGET_OS_IPHONE
    typealias RAImage = UIImage
    typealias RAImage = UIFont
#endif

And this:

var image = RAImage()
#if TARGET_OS_IPHONE
    UIGraphicsBeginImageContextWithOptions(textRect.size, false, 0.0)
    text.drawInRect(textRect, withAttributes: textAttributes)
    image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
#elseif TARGET_OS_MAC
    image = RAImage(size: textRect.size)
    image.lockFocus()
    text.drawInRect(textRect, withAttributes: textAttributes)
    image.unlockFocus()
#endif

Pretty cool.


Getting NSToolbar Height From an NSWindow in Swift

Jan 15, 2015 at 01:58PM

Adapted from this old Apple example:

import Cocoa

extension NSWindow {

    func toolbarHeight() -> CGFloat {
        var toolbar: NSToolbar?
        var toolbarHeight = CGFloat(0.0)
        var windowFrame: NSRect

        toolbar = self.toolbar

        if let toolbar = toolbar {
            if toolbar.visible {
                windowFrame = NSWindow.contentRectForFrameRect(self.frame, styleMask: self.styleMask)
                toolbarHeight = NSHeight(windowFrame) - NSHeight(self.contentView.frame)
            }
        }

        return toolbarHeight
    }
}

If you find that this code is returning 0 but you're positive you have an NSToolbar, check that Full Size Content View isn't selected in the attributes inspector of your storyboard.


BBEdit Codeless Language Module for MongoDB Config Files

Jan 15, 2015 at 09:59AM

Apparently it bothers me enough when syntax highlighting isn't working for an incredibly specific type of file in BBEdit that I'll spend an hour or so writing scripts to scrape webpages and fix it.


Re: New WIRED Offices

Jan 14, 2015 at 03:36PM

Unfortunately, too often the place where we do that important work looks, at best, like a dorm room. It’s an embarrassment: coffee stains on walls (and countertops and desks), overflowing compost bins, abandoned drafts of stories and layouts (full of highly confidential content), day-old, half-eaten food, and, yes, I’m going to say it, action figures. Please. WIRED is no longer a pirate ship. It’s the home of world-changing journalism.

What an asshole.

via Moltz