Category: Apple

Recursion in Swift

Recursion is when a method or function calls itself.

[c collapse=”False”]
//depending on what number you give to N, the function will call itself that many times, subtracting 1 from the original N each time through to pass as an argument.

func thisFunctionCallsItself(thisManyTimes: Int) {

//The next few lines are to set up the proper suffix on the printed result string
var mySuffix = String()
//let’s get the last two digits from thisManyTimes
let lastTwoDigits = thisManyTimes % 100
switch lastTwoDigits {
case 10…20:
mySuffix = "th"
//get the last digit
let lastDigit = thisManyTimes % 10
switch lastDigit {
case 1:
mySuffix = "st"
case 2:
mySuffix = "nd"
case 3:
mySuffix = "rd"
mySuffix = "th"
//OK that it.

//below is where the function calls itself
if thisManyTimes != 0 {
thisFunctionCallsItself (thisManyTimes – 1)
print("This is the \(thisManyTimes)\(mySuffix) time that this function has called itself.")


//call the function.



Why we will be drooling over the new Mac Pro

It looks like something out of a science fiction movie (and apparently it looks a lot like a Japanese trash can too), but the Mac Pro will be a piece of reality in a few months.


People who love Apple hardware, and use computers for graphics rendering or video will be dying to get their hands on this device. Here are the top five reasons why we will want to see the new Mac Pro on our desktop:

1. The Design. What is it? A coffee grinder? It’s a bit weird for a computer, but increadibly sleek at the same time. It reminds me a bit of the SGI O2, but way cooler. This device will probably be a major iconic design in the Apple’s historical lineup. The current Mac Pro is a beautiful machine, but the new Mac Pro makes the old cheese grater look retro.

2. Power. With up to 12 cores of Xeon 5 processor and 40 GB per second PCIe bandwidth, the new Mac Pro can deliver cpu performance up to 2x the current Mac Pro.

3. Speed. The new Mac Pro will support up to 128GB of ram and feature 60GB per second memory bandwidth, 2x the current bandwidth. The storage is “Next generation PCIe flash storage” that can read/write at 1250MB per second. 20Gb per second thunderbolt expansion ports. Super fast.

3. Graphics. The new Mac Pro will have, standard, two AMD FirePro GPUs with up to 6GB of dedicated VRAM graphics. The machine supports 4k video and up to three 4k displays.

4. Size. It’s like an eighth the size of the current Mac Pro.

Gradients v2.1 is available

Gradients is a photo effects app that allows users to build their own effects with gradient images. Over 40 template effects are included. I think this is a rather unique app. Please check it out. It’s only a buck: Gradients v2.1.


[button label=”Gradients On The App Store” url=”″ color=”#f05134″ target=”_blank”]

XCode breakpoint tip

Use breakpoints to replace NSLog statements while debugging your code.

Screen Shot 2013-05-09 at 9.08.49 AM


1. Add a break point.
2. Hold option + command and click the break point to edit it.
3. Tap the add action button.
3. Add an action or expression like below.

LLDB (debugger) action
[c collapse=”False”]
po myVar

[c collapse=”False”]
expr (void)NSLog(@"myVar = %d", myVar)

Select “Automatically continue after evaluating” to continue without stopping the code.


1. Easier to manage: e.g. you can view all the breakpoint and more in the breakpoint navigator (second button from the right in the navigator pane).

2. You can edit the actions or expressions, or add breakpoints while the code is running.

Source: 2012 WWDC video: Debugging in XCode. Much more information in this video.

Basic Apple Script

On your desktop, create a folder called test. Inside the test folder, create a folder called tester. Now open a finder window and navigate to a random location, like home, but not one of these folders.

Now open the AppleScript Editor and paste the code below into the AppleScript Editor input window (the top pane).

[text collapse=”False”]
tell application "Finder" to set the target of the front Finder window to folder "tester" of folder "test" of desktop

The finder will automatically open the tester folder in the foremost open window.

A complete tutorial here:

Magic Prefs

You’re not really using your Mac Magic Mouse until you get MagicPrefs.

Here are my current preferences, to combat carpal tunnel (hand fatigue). Note the Taps section. Set up this way, right and left clicks can be accessed via tap, saving the strain of a click.

The Magic Prefs app also includes settings for your track pads.

Silhouetter iOS App

Silhouetter app automatically colorizes images, and at the same time deepens the mid-tones and blacks. The effect adds an intriguing and dramatic mood to almost any snapshot.

A slide show of images produced with Silhouetter iOS app, designed in collaboration with Jeshua Lacock at Please follow this link to buy a copy on the App Store.