Syntax highlighting for Swift in BBEdit and TextWrangler

Big thanks to Curt Clifton ( – his bio indicates that he’s with the Omni Group!) for creating this codeless Language Module for Swift that can be used in BBEdit and in TextWrangler.

A BBEdit Codeless Language Module for Swift

Curt indicates there are some limitations to codeless language modules:

Keyword, comment, and string highlighting work. Top-level classes, structs, enums, functions, and extensions are indexed and can be folded. Because of limitations in the matching power of codeless language modules, nested declarations are not indexed and are not fold-able.

However, it works great if you want to do some Average Joe coding in Swift in TextWrangler or just see your .swift files highlighted outside of Xcode.

Installation is super easy:


  1. Copy the file swift.plist to ~/Library/Application Support/BBEdit/Language Modules. You may have to create the Langauge Modules folder if it doesn’t exist.
  2. Quit and relaunch BBEdit.

…and for TextWrangler it’s just as simple:


  1. Copy the file swift.plist to ~/Library/Application Support/TextWrangler/Language Modules. You may have to create the Langauge Modules folder if it doesn’t exist.
  2. Quit and relaunch TextWrangler.

Smoother transitions when showing a View Controller with a UINavigationBar in Swift

Here’s the scenario. You want to display a modal view controller without a navigation bar, and then from that view controller you want to navigate to another view controller that displays a navigation bar.

First to get things set up, in the Storyboard we set up the view controller that would be displayed modally. We create a view controller, perform the Editor -> Embed in -> Navigation Controller. Then, in the viewWillAppear method, we hide the navigation bar programmatically.

It turns out that there are two ways to do this and, at least in my case, one way turned out to be better than the other. The first way I tried worked, but the animation for the transition from one view controller to the next looked a little odd.

The first way is the more obvious of the two, because you can simply just set the hidden property of the navigationBar like in the following example:

self.navigationController?.navigationBar.hidden = true

There is also another way to do the hiding and showing of the UINavigationBar, and the second way is do do it via the UINavigationController, as in the second example:

self.navigationController?.setNavigationBarHidden(true, animated: true)

There are two advantages to doing it the second way. First, because you get a method to hide and show the navigation bar, you get the additional animated parameter that you can set.

The second advantage is that when you use it in this way with the animated parameter set to true, iOS performs a slightly more smooth transition.

Your mileage may vary, so try both ways and see which you personally like best.

How to create an Objective-C Bridging header

Super important to know during this time of Objective-C to Swift transition. I’ve had to use this technique and it will be good for all Swift developers to have in their kit-bag until we can finally be 100% Swift.

How to create an Objective-C Bridging header – iOS-Blog
So you want to use an Objective-C Library or SDK in your Swift application eh? Well do not fret. This quick tutorial will show You how you can create an Objective-C Bridging Header in your Swift application so you can use them both together and seamlessly.

UIView Animation with Swift

Here is a very simple way to do UIView Animations in Swift.

First, you create an IBOutlet for a constraint created in Interface Builder in Xcode – in my case, I had a constraint that anchored to the bottom of the containing view. In the code example, the constraint is named “constraintToAnimate”. You just control drag from the Storyboard to your code as you would when connecting a control, but in this case you connect a constraint. It will look something like this (the name of your constraint will hopefully be different):

    @IBOutlet weak var constraintToAnimate: NSLayoutConstraint!

The following snippet is basically a straight-up conversion of Apple’s own Objective-C example given in the documentation article Auto Layout by Example in the Animating Changes Made by Auto Layout section (you may need to scroll down to find that section).

    UIView.animateWithDuration(0.3, animations: {
        // make constraint changes here...
        self.constraintToAnimate.constant = 250 // your value here.
        }, completion: {
            (value: Bool) in
            // completion code here...

Basically, in pre-Auto Layout days you would just animate the frame. Today you just animate the constraint. It works great and once you get your head wrapped around it, it’s pretty straightforward.

UIDatePicker Height Inconsistency at Runtime [#iOSDev, #SwiftLang]

Apple needs to fix this one.

There is an inconsistency in the way that the UIDatePicker is rendered in Storyboards in Xcode vs. their rendering at runtime. This problem set me back longer than it should have this morning, since its effect was tricky to diagnose. The basic consequence of this was that the custom UIButton I had attached to the top of the date picker (inside a UIView) was not receiving taps and for the life of me I couldn’t figure out why…

First, to diagnose the problem, I used this tip to get the UIView recursiveDescription method working in my Swift project, and I was able to get a dump of the view hierarchy. From that, I could tell that the UIView I had created as a container was at a Y value of -54, and was therefore outside the bounds that I had set for the custom view, and was not receiving tap events.

Then I stumbled on this Stack Overflow post by Florian Mielke, which suggested that there is a typo-bug somewhere in Xcode or iOS in the rendering of UIDatePicker in a Storyboard vs. Runtime:

iphone – iOS 7 UIDatePicker height inconsistency? – Stack Overflow

“I can confirm that using UI(Date)Picker in storyboards has a different height (162.0) than in “reality” (216.0). Therefore you have to adjust the space to container view to fit that ‘real’ date picker height or try to solve it using auto-layout.”

Reconciling that with the output from recursiveDescription totally agreed with this, and once I increased the size of my custom view, taps were once again being received by the Done button!

How to read a JSON file from your bundle and output the contents as a String in Swift

When you’re first getting started with Swift, even the easiest things may seem a challenge. For example, reading in a JSON file, converting its contents to a String and then sending the result to the console may take a while to figure out (at least, it did for me…).

I needed to do this in my current project for diagnostic purposes, and thought it might be helpful to others, so here’s the little code snippet I used:

    // 1
    let filePath = NSBundle.mainBundle().pathForResource("MyJSONFileName",ofType:"json")
    // 2
    var readError:NSError?
    // 3
    if let data = NSData(contentsOfFile:filePath!, options:NSDataReadingOptions.DataReadingUncached, error:&readError) {
        // 4
        let stringData = NSString(data: data, encoding: NSUTF8StringEncoding)
        // 5
        println("data read: \(stringData)")

As you can see, it’s pretty straightforward.

  1. Create a file path to the file.
  2. Declare an NSError object for use in the reading (this example just eats the error, however).
  3. Read in the data from the JSON file.
  4. Create an NString object, initializing it with the NSString(data:encoding:) method.
  5. Output the result.

How to REALLY Add or Delete a Task or a Container in a Control Flow in Visual Studio 2013


I was staring at Visual Studio 2013 in disbelief, looking at the empty Toolbox thinking I missed an installation step, even though all the other functionality of SQL Server Integration Services (SSIS) was working just fine.

After doing a little digging (this time Stack Overflow did not help), it turns out that SSIS has its own dedicated Toolbox, and it’s basically hidden.

Thanks to an article by Robert Bigec, the answer is pretty simple, but not obvious.

The Empty Toolbox – SSIS 2012 | Robert’s Spout.ToString()

I stared at this toolbox in disbelief. White and spacious with a confirming message that gave me no comfort: “There are no usable controls in here … “. What happened to the Source Assistant? Where in the world is the Destination Assistant? Merge: gone! Data Conversion: gone! Forget about adding an Execute SQL Task, this is not happening! I guess, I’m not making any more Integration Services packages, unless I work on another computer, or go back to 2008. Maybe this is a bug. It could be, because it is a new product, right? Maybe I should file a bug report. No, it can’t be a bug, someone would have reported it by now. I must have done something to mess it up. I vaguely remember opening up another project to look at it and closing the toolbox because it was in the way, but it should come back shouldn’t it? Yeah, it should come back, but it didn’t. Desperately searching for some way to get the items back, I trolled the menus, scoured the icons and noticed this. Click! It’s back. Yay! Hoorah! Happy days are back again!

Thanks to Robert for the answer!


Smashing Magazine on Lo-Fi Prototyping

Many of my colleagues know that I like to do lo-fi prototypes since I can iterate so much faster on them, get a sense of whether it’s a good design choice or not.

So, it was really nice to see this article on Smashing Magazine by Laura Busche on the subject, entitled The Skeptic’s Guide To Low-Fidelity Prototyping | Smashing Magazine

In it, she shows that:

Low-fidelity prototypes, in particular, are rough representations of concepts that help us to validate those concepts early on in the design process. Throughout this article, we will look at some of the features that make low-fidelity prototyping a unique tool to radically improve your work and to build an environment in which users’ needs can be truly realized.

As it turns out, I’ve recently been using lo-fi paper prototyping for my new app design and it’s been very helpful and, best of all, not time consuming.

Hope this article helps other designers and developers!

Using Temporary Tables in SQL Statements

Found this to be a really helpful tip from Using Temporary Tables in SQL Statements. I wanted to be able to quickly construct a temporary table within a stored procedure and this was just a super-simple set of examples to get that going.

Hope others find it useful as well!

Using Temporary Tables in SQL Statements

Temporary tables can be used in the SQL statement wherever the regular tables can be used. To identify a table being a temporary table in the SQL statement, prefix the table name with the ‘#’ character.


// Create a temporary table named Temp1 with two columns
CREATE TABLE #Temp1 ( Name Char( 30 ), seqid integer );

// This example creates two temporary tables for intermediate results
// Step 1. Create a temporary table named DeptCount and at the same time
// populate it with summary data from an existing table in the
// database

SELECT deptnum, count(*) as NumEmployees
INTO #DeptCount
FROM employees
GROUP BY deptnum

// Step 2. Create another temporary table named LocCount which list the
// number of employees in each location for each department.

SELECT deptnum, location, count(*) as cnt
INTO #LocCount
FROM employees
GROUP BY deptnum, location

// Finally using the 2 temporary tables to list the percent of employee
// on each location for each department

SELECT a.deptnum, a.location, ( a.cnt * 100 ) / b.NumEmployees As PercentAtLocation
FROM #LocCount a, #DeptCount b
WHERE a.deptnum = b.deptnum

Gus Mueller on The Wilderness

I’ve been feeling pretty much like this expresses lately, even with all this exciting news lately about iOS 8, iPhone 6/6 Plus, and ?WATCH (Apple WATCH):

The Shape of Everything: The Wilderness

However much time I’ve been doing this for, and no matter how much practice I put into it, there’s one thing that always sneaks up and pulls the rug right from under me. It’s usually between major releases, but not always. It’s a period of time where I’m pretty lost, and I don’t know what to do. I have feature lists, I have open bugs to fix, and I have an outline of where the app is going. But I feel mentally incapacitated, like I’m getting nothing done.

The good news is that I’ve got some exciting ideas brewing that I hope will come to shape soon…