Matt Gallagher: Cocoa with Love

Articles about Swift, Cocoa, software design and programming.

  • Mar 1, 2009

    Objective-C era

    An Asteroids-style game in CoreAnimation, Part Three.

    How would you write an arcade-style 2D game in CoreAnimation? I'll show you how to write a resolution independent, high-speed, model-view-controller designed, Asteroids-style arcade game using CoreAnimation as the screen renderer. In this third of four parts, I add the logic for the game and game objects and present the finished code for the project.

    Read article

  • Feb 22, 2009

    Objective-C era

    An Asteroids-style game in CoreAnimation, Part Two.

    How would you write an arcade-style 2D game in CoreAnimation? I'll show you how to write a resolution independent, high-speed, model-view-controller designed, Asteroids-style arcade game using CoreAnimation as the screen renderer. In this second of four parts, I'll create basic objects in the game and their corresponding CoreAnimation Layers on screen.

    Read article

  • Feb 17, 2009

    Objective-C era

    An Asteroids-style game in CoreAnimation, Part One.

    How would you write an arcade-style 2D game in CoreAnimation? Over the next few weeks, I'll show you how to write a resolution independent, high-speed, model-view-controller designed, Asteroids-style arcade game using CoreAnimation as the screen renderer. In this first of four parts, I'll detail the concept for the overall application and show you how to create a resolution independent window for the game.

    Read article

  • Feb 7, 2009

    Objective-C era

    Breadth-first traversal of a graph of Objective-C objects

    If you have a collection of interconnected objects in Objective-C, what is the best way to traverse them all in order from nearest to furthest? Are the NSMutableSet methods good for tracking already-visited nodes? How much overhead does an NSMutableArray FIFO queue impose relative to a depth-first search (which doesn't require a FIFO queue)? Does NSMutableArray perform better if objects are pushed onto the front, or the back? In this post, I present answers to these questions and more.

    Read article

  • Feb 1, 2009

    Objective-C era

    Interprocess communication: snooping, intercepting and subverting

    When Xcode is running, Interface Builder seems to magically know which classes, methods and variables are available. Where does Interface Builder get this information? How can you recreate this effect when editing source files in an external editor without Xcode running? This is the story of how I investigated the communication between Xcode and Interface Builder, so that I could recreate it for myself.

    Read article

  • Jan 23, 2009

    Objective-C era

    Multiple virtual pages in a UIScrollView with just 2 child views

    The UIScrollView and UIPageControl in Cocoa Touch allow for user interfaces with multiple panning pages. The sample project that Apple provides (PageControl) keeps all child views for every page in a lazily loaded array. I'll show you how you can implement this using just two child views, no matter how many virtual pages you wish to represent.

    Read article

  • Jan 18, 2009

    Objective-C era

    Demystifying NSApplication by recreating it

    In this post I will recreate code that is normally concealed between the NSApplicationMain call (invoked in a Cocoa application's main function) and the sendEvent: method (which distributes the events to windows and views from the main run loop). By recreating this code for you, I hope to explain the steps that occur between program startup and the dispatch of events to your code — so you can gain greater understanding of what NSApplication does on your behalf.

    Read article

  • Jan 5, 2009

    Objective-C era

    Serving an NSManagedObjectContext over an NSConnection

    In this post, I'll show you how you can serve a Core Data document over a network using NSConnection. This arrangement will never be as efficient or safe as writing your own code to communicate the data over the network but the promise of transparent and automatic networking seemed too tempting to pass up.

    Read article

  • Dec 27, 2008

    Objective-C era

    Heterogeneous cells in a UITableViewController

    This post looks at writing a UITableViewController for a table view that contains behaviorally unrelated rows — a common occurrence on the iPhone for tables containing multiple groups. I will present a simple alternative to Apple's UITableViewController template code that will reduce complexity and code as well as refocus areas-of-concern for this heterogeneous arrangement.

    Read article