Matt Gallagher: Cocoa with Love

Articles about Swift, Cocoa, software design and programming.

  • Sep 20, 2010

    Objective-C era

    Minimalist Cocoa programming

    In this post, I build and run a Cocoa Mac application on the command-line. This might not sound like a very difficult goal but I'll attempt to follow an additional constraint: use as few tools, components, classes and even lines of code as possible; truly minimalist Cocoa programming. The goal is to create an application that qualifies as a proper Mac application (including a menubar and a window) but without using Xcode, without an Info.plist file, without NIB files, without Interface Builder and without even using a text editor other than the Terminal itself.

    Read article

  • Sep 14, 2010

    Objective-C era

    The overhead of spawning threads (a performance experiment)

    In this post, I take a casual look at the relative performance overheads handling tasks in different ways: performing all tasks in the main thread, sending tasks to a single worker thread, spawning new threads for every task, and using Grand Central Dispatch (GCD). This won't be a particularly advanced investigation, simply a quick overview of simplicity versus performance in job management.

    Read article

  • Aug 30, 2010

    Objective-C era

    Alternative Objective-C object allocation for large arrays

    In this post, I'll show you how you can create objects without using the standard instance allocation process (either +[NSObject alloc] or class_createInstance()). I'll also explain why you might do this — the benefits and drawbacks to a custom object creation process.

    Read article

  • Jul 15, 2010

    Objective-C era

    Is a virtual machine for Cocoa programming inevitable?

    Recent articles by Jesper have re-ignited some discussion about whether Apple might be working on another programming language to replace Objective-C. Neither of these articles closely examined a related but possibly more important question: is Apple planning to move application development to a virtual machine? In this article, I'll look at why I think moving to a virtual machine might happen along with a possible language transition.

    Read article

  • Jun 22, 2010

    Objective-C era

    The design of every Mac application

    I was recently asked by a reader if I used any modelling program to model the classes and relationships in my Mac applications. The answer is no, I don't model the application side of my programs. The reason for this is not because applications are always small and simple. The reason is that all applications have approximately the same design — eventually everything in a well-designed application becomes intuitive.

    Read article

  • Jun 10, 2010

    Objective-C era

    Sorting an NSMutableArray with a random comparison method

    If you sorted an NSMutableArray with a comparison method that randomly returns either higher or lower, would the result be an even, random distribution? Spoiler: no it won't but the actual distribution is interesting nonetheless. I'll show you what would happen if you did sort this way (and also show you how to correctly randomize an array if you did want an even distribution).

    Read article

  • Jun 2, 2010

    Objective-C era

    Avoiding deadlocks and latency in libdispatch

    The system-wide thread pool of libdispatch's global queue is an easy way to efficiently manage concurrent operations but it is not the solution to all threading problems and it is not without its own class of problems. In this post I look at deadlocks and latency problems that are inherent in thread-pool based solutions like libdispatch's global concurrent queue so that you will know when you should use this option and when you need something else.

    Read article