Matt Gallagher: Cocoa with Love

Articles about Swift, Cocoa, software design and programming.

  • Oct 10, 2008

    Objective-C era

    WorldTimeConverter: Dates and timezones in Cocoa

    Recently, I searched for a world time converter — one that would handle future dates as well as the current time. There are web versions but I didn't find a genuine Mac OS X application that matched my desires. How hard could it be? The answer is 1 subtraction — provided you can find the right values to subtract. Read on and I'll show you how it's done.

    Read article

  • Oct 3, 2008

    Objective-C era

    Sliding UITextFields around to avoid the keyboard

    It's an iPhone post because I finally can. Here's a good way to slide your view around when editing UITextFields so that they never get trapped under the onscreen keyboard. I'll be giving a talk at the Brisbane Cocoaheads meeting this Monday evening (Oct 6). Come along and heckle.

    Read article

  • Sep 28, 2008

    Objective-C era

    Streaming and playing an MP3 stream

    This week, I present a sample application that streams and plays an audio file from a URL on the iPhone or Mac. I'll show how the application was written by expanding upon Apple's AudioFileStreamExample, including a work-around for an Audio File Stream Services' crash bug when handling streaming MP3s.

    Read article

  • Sep 20, 2008

    Objective-C era

    A Cocoa application driven by HTTP data

    Here's a tiny application that queries a webpage via HTTP, parses and searches the response and presents the results in a neatly formatted window. In essence, it's what many Dashboard widgets and iPhone apps do but I'll show you how to do it in a regular Cocoa application.

    Brought to you by FuelView, an iPhone application I wrote for fetching FuelWatch information in Western Australia.

    Read article

  • Sep 13, 2008

    Objective-C era

    Drawing gloss gradients in CoreGraphics

    This post presents a function &mdash DrawGlossGradient(CGContextRef context, NSColor *color, NSRect inRect) &mdash that will draw a "gloss" gradient in a single statement. All colors in the gradient are calculated from the single color parameter.

    Read article

  • Sep 9, 2008

    Objective-C era

    Parametric acceleration curves in Core Animation

    CAMediaTimerFunction is used to control basic acceleration along a path in Core Animation but is very limited in what in can do. In this post, I look at the mathematics behind CAMediaTimerFunction and present a sample application that simulates some functions that CAMediaTimerFunction can't achieve by using parametric CAKeyframeAnimation values.

    Read article

  • Aug 31, 2008

    Objective-C era

    Application Design in AppKit

    This is a discussion of high-level application design in Cocoa that aims to explain the major class roles in an AppKit application and how they are connected. I'll show you much more detail than simply "Model-View-Controller" and I also give a specific example of how all the concepts apply to a real application.

    Read article

  • Aug 24, 2008

    Objective-C era

    Safely fetching an NSManagedObject by URI

    If you need to store a reference to an NSManagedObject outside of an NSManagedObjectContext, then you'll need to convert NSManagedObjects to URIs and back again. At first glance it looks like a simple method will do all the work for you but in reality you must be careful when getting the object back. I'll show you the way to convert an object to a URI and get it back safely.

    Read article

  • Aug 16, 2008

    Objective-C era

    In defense of Objective-C 2.0 Properties

    Of all the new features in Objective-C 2.0, none were as controversial as declared properties. Judging from the attacks, much of the controversy stems from a misunderstanding about the role that properties occupy in a class. In this post, I'll explain why properties are useful in Objective-C — and it isn't auto-generated getters and setters or the dot syntax.

    Read article

  • Aug 9, 2008

    Objective-C era

    NSArray or NSSet, NSDictionary or NSMapTable

    Some types of data can be held in more than one kind of collection. Unordered objects that are already guaranteed unique can be sensibly held in an NSArray or an NSSet. Anything an NSDictionary can hold can be held in an NSMapTable. In this post, I measure the performance of creating and using these different options to help you choose which one is right for you.

    Read article