Matt Gallagher: Cocoa with Love

Articles about Swift, Cocoa, software design and programming.

  • Dec 18, 2008

    Objective-C era

    OrderedDictionary: Subclassing a Cocoa class cluster

    The default Cocoa collection classes are highly capable but there are situations where you may need to override them to alter their functionality. I'll explain when and how you should do this with an example class: OrderedDictionary (an NSMutableDictionary subclass that maintains ordering of its keys).

    Read article

  • Dec 12, 2008

    Objective-C era

    Drawing a custom window on Mac OS X

    Occasionally, you may want a window to look completely different to the standard window styles provided by Apple. This post will show you how to draw a custom window and implement close, resize and drag functionality.

    Read article

  • Dec 6, 2008

    Objective-C era

    Instance variable to synthesized property (an Xcode user script)

    Xcode user scripts take the repetition out of many aspects of programming. To show you how this can work, here's a script I wrote to turn an instance variable into a property (complete with declaration and synthesis) just by selecting the variable and invoking the script.

    Read article

  • Nov 29, 2008

    Objective-C era

    Method invocation formatting styles in Objective-C

    While most traits of Objective-C follow consistent styles, method invocation formatting — arguably a defining characteristic of the language — does not. In this post, I'll look at a handful of approaches that different programmers use to format their method invocations and discuss their advantages and disadvantages.

    Read article

  • Nov 23, 2008

    Objective-C era

    Automated user interface testing on the iPhone

    Automated testing of application user interfaces can be tricky since user interfaces are designed for use by humans not automated tools. The iPhone is particularly challenging since existing tools that aid user interface testing on the Mac are not available. This post will show you a way to run automated, scripted tests on an iPhone app's user interface.

    Read article

  • Nov 16, 2008

    Objective-C era

    Singletons, AppDelegates and top-level data.

    If you require only a single instance of an object in your application, where should it go? How should you control and manage it? Here are some different approaches, their implementations, their strengths and their weaknesses.

    Read article

  • Nov 10, 2008

    Objective-C era

    Simplifying your code using NSDictionary

    Computers programs are good at mindless repetitive tasks, they are not good at broad decision trees. In this post, I will show you a way of eliminating conditionals from your code that are based on program state by using an array of NSDictionary objects to maintain state.

    Read article

  • Oct 31, 2008

    Objective-C era

    Using libxml2 for XML parsing and XPath queries in Cocoa

    NSXMLDocument is the normal tree-based XML parser in Cocoa. But if you're writing for the iPhone, this class isn't available. Even on the Mac, sometimes you want tree-based parsing without the full overhead of NSXMLDocument. Here's how to use libxml2 to perform tree-based parsing in a Cocoa-friendly way.

    Read article

  • Oct 25, 2008

    Objective-C era

    Debugging tips for Objective-C programming

    This post is about getting extra information from your program at runtime. Xcode and gdb both support a wide range of information access tools — but you need to know that they're there. Here are some Objective-C specific gdb tips and commands that all Cocoa programmers should know.

    Read article