Tuesday, March 3, 2015

DRTabBarController: UITabBarController Replacement

If you've ever tried to put a UITabBarController inside a UINavigationController, you've run into trouble. DRTabBarController is a drop-in UITabBarController replacement that fixes this issue.

Tuesday, February 17, 2015

GameLoop in Swift

I never realized that you're not supposed to use NSTimer because it doesn't line up with the frame rate. Who knew? Anyway, here's my GameLoop class (Swift). Note: it has to extend NSObject otherwise you get weird selector-not-found errors.

Friday, January 23, 2015

Sizing Subview to Superview Using Autolayout with VFL and Cartography Using Swift

In talking with the Lead Developer of Mitosynth, I got inspired to get deep into Swift, Autolayout, and Cartography. And in the last 24 hours, I've been tearing my hair out with Autolayout in Cocoa using Swift. I finally got it down to a single question on Stackoverflow.

The answer to that question opened my eyes: Cocoa was "automatically adding constraints!" So without further ado, here are all my concepts wrapped up in one. This example uses Autolayout, VFL (using a nice category I made for Swift), and Cartography, too. Whoot!

VFL, Autolayout in Swift

I don't really understand this Visual Format Language (VFL_ stuff, and it rarely does what I want, but if you read the Apple page on it you'll get the idea. Anyway, here's an extension to use them in Swift. Substitute UIView for NSView if you're working on iOS Here is is on SO: link

Wednesday, January 21, 2015

My System: Workflowy for GTD

I can no longer fight it. I use Workflowy for everything. Using an external app for my todo list is just silly (though Wunderlist is awesome). So... here it is:

Never have a task list. Use tags and build out your world wherever you are.
  • Every Node is #project or #task or maybe a #superproject
    • Everything else is somewhere above, below, or in-between. So most of your Workflowy tree is not seen in the searches below
    • In GTD talk, a project is a series of actions needed to produce an outcome
    • In GTD talk, a task is something you can do...
      • Ramble:
        • This could contain other subtasks
        • But these are the things that a project is going to use to represent itself on the big todo list
  • Statuses
    • #next
      Last step before Complete
    • #waiting
      Waiting for an external event or person
    • #reminder
      In some external system like Reminders
  • Priorities get set by number of asterisks, consecutively, so highest is *****
  • Notes
    • Searches
      All the searches (vary the number of asterisks by deleting with backspace)
      • #task #next *****
      • #task #reminder *****
        Tasks in a reminder system elsewhere
      • #task #waiting *****
      • #task -#waiting -#next -#reminder ******
        Non-queued tasks for moving to Next or Later
      • #project *****
    • This way stuff goes from next to completed

Associated Objects in Swift

Associated Objects are a great way to put properties on classes that you do not control.

For NSObject Subclasses

You must use this method for String and Array, because they are not classes: they're structs. The toll-free bridging to NSObject subclasses allows this to work.

For Custom Objects

Here it's a lot simpler, but since AnyObject is a protocol, you have to use an actual class. This definitely limits the utility of associated objects. My much longer, rambling post on Objective-C and Associated Objects.

Thursday, September 11, 2014

Evernote Links, Old Style

Well, Evernote changed the way they do links. The problem with the https:// links, instead of the older evernote:/// links, is that they require an active Internet connection. And then you have to be logged into your account, etc. And then... they don't work on iOS.

I need this all to be great for Workflowy, so here's a rough Ruby script to handle the issue for OSX.

evernote-links, Ruby Script: Set to Executable!

evernote-links, Applescript for Spark

Use it with Spark to map this to a keystroke. Use an Applescript to launch the Ruby script like this (pointing to wherever you put evernote-links):