Recursion in Swift

Posted by on Mar 21, 2016 in Apple, apps, code, programming, Swift | No Comments

Recursion is when a method or function calls itself.

//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.


NSUserDefaults tutorial, on icodeBlog

Posted by on Jun 29, 2013 in Apple, apps, code | No Comments

Check out this article if you need information on using NSUserDefaults in Xcode.

iPhone Programming Tutorial – Saving/Retrieving Data Using NSUserDefaults

If you have any trouble saving and retrieving the defaults, try synchronizing:

    [[NSUserDefaults standardUserDefaults] synchronize];

Why we will be drooling over the new Mac Pro

Posted by on Jun 16, 2013 in Apple | No Comments

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

Posted by on Apr 26, 2013 in Apple, apps | No Comments

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.


Gradients On The App Store

XCode breakpoint tip

Posted by on Mar 9, 2013 in Apple, apps, code | No Comments

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

po myVar


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

Posted by on Jan 9, 2013 in Apple, Mac | No Comments

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).

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

Posted by on Dec 28, 2012 in Apple | No Comments

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.

Programmatic UIpopoverController

Posted by on Jun 30, 2012 in Apple, apps, code | One Comment

Here is an Xcode project that creates an iPad UIPopover with programmatically created glossy buttons (with core graphics). Attempts to match the generic Apple popover buttons.

Silhouetter iOS App

Posted by on Feb 2, 2011 in Apple, apps, Hire Page, photography | No Comments

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.

Load More