Matt Gallagher: Cocoa with Love

Articles about Swift, Cocoa, software design and programming.

  • Sep 16, 2009

    Objective-C era

    Building for earlier OS versions from Snow Leopard

    It is very easy, when developing on a new operating system, to create projects that won't run on any previous OS version. To ensure backwards compatibility, there are Xcode and gcc options that allow you to build while maintaining support for earlier OS versions. In this post, I'll look at the ways in which this compatibility is controlled and some of the new ways it can go wrong on Snow Leopard.

    Read article

  • Sep 9, 2009

    Objective-C era

    Creating alpha masks from text on the iPhone and Mac

    Alpha masks are a powerful way to create graphical effects in your program. In this post, I'll show you how to create an alpha mask from a text string and use that mask to create text-based effects with an image. I'll also show you how to do this on the iPhone and the Mac, so you can see the differences between these platforms in this area.

    Read article

  • Sep 1, 2009

    Objective-C era

    An NSSplitView delegate for priority based resizing

    The default resizing mechanism in NSSplitView is proportional resizing — if the NSSplitView changes size, each column resizes by an equal percent. This works badly in the common case where the columns in a split view are used to separate a side panels from a main view area (for example the "source list" in iTunes or the file tree in Xcode). In this post, I'll show you a delegate class that configures a split view for this side panel and main view behavior — resizing the views in a split view based on a priority list.

    Read article

  • Aug 21, 2009

    Objective-C era

    StreamToMe iPhone App Released

    StreamToMe is an iPhone app I've written that streams video in most common formats from your Mac to the iPhone/iPod Touch — without prior conversion or copying. It supports the TV out cable for the iPhone, turning your iPhone+Mac into a wireless media center. I'm excited that it's finally on the App Store because I've been using it non-stop during development and I'm really happy with it.

    Read article

  • Aug 21, 2009

    Objective-C era

    Adding shadow effects to UITableView using CAGradientLayer

    Shadows can be a useful effect, drawing attention to the content of your view by separating the view from the background. They also look cool. In this post, I'll show you how to add shadows to a UITableView using three CAGradientLayers — one above the first row, one after the last row and one for under the navigation bar.

    Read article

  • Aug 14, 2009

    Objective-C era

    Animating a window to fullscreen on the Mac

    Many Mac OS X applications animate their regular application windows to fullscreen but since there's no dedicated method for the task, there's no standard Apple documentation that covers the operation. If you look for examples on the web, you'll find numerous examples that perform this operation using old APIs or methods intended for permanently fullscreen games (the wrong approach for an application window). In this post I'll show you my preferred approach for making an application window fullscreen, with continuous display and smooth animation.

    Read article

  • Aug 9, 2009

    Objective-C era

    Safe, threaded design and inter-thread communication

    The Foundation framework provides all the tools you need for inter-thread communication — without needing to handling locks and synchronization yourself. I'll show you Cocoa's tools for inter-thread communication, notifications and easy synchronization — including far simpler code for posting NSNotifications on the main thread than the Cocoa documentation suggests.

    Read article

  • Aug 3, 2009

    Objective-C era

    Control and configuration of applications through Info.plist

    The Info.plist file is home to the metadata about your application used by the operating system. Most Cocoa programmers know that it stores the bundle identifier, icon name and version number of an application but the Info.plist can also control access to essential iPhone hardware resources and can change the very nature of your Mac OS X applications. In this post, I'll cover basic Info.plist usage and also explain some of the rarer settings.

    Read article

  • Jul 27, 2009

    Objective-C era

    Rules to avoid retain cycles

    Normally in Objective-C, if you follow the basic rule of maintaining a positive retain count for everything you need to hold onto and releasing when you're done, memory management will "just work" — until you create a retain cycle and suddenly no objects in the cycle will ever be freed. In this post, I'll explain retain cycles, common cases where they occur and the solutions to these problems.

    Read article

  • Jul 23, 2009

    Objective-C era

    Temporary files and folders in Cocoa

    If you need to use temporary files in your application and you search the Cocoa documentation for "temporary file", you're unlikely to find anything that explains how to create one. Since temporary files and folders are subject to a number of security issues and race conditions when done wrong, it is important to know the correct way to create them. I'll show you some code that you can copy and paste into your applications to create temporary files and folders safely.

    Read article