top
AboutArchiveSearch zqueue.com
Matt Gallagher: Cocoa with Love
  • Tracking tasks with stack traces in Swift

    Feb 28, 2016

    In this tongue-twister titled article, I discuss capturing control flow information with stack traces during ongoing tasks to aid debugging. Also included: a reimplementation of NSThread.callStackReturnAddresses in Swift for faster and more flexible stack traces.
    Read more...
  • Use it or lose it: why safe C is sometimes unsafe Swift

    Feb 16, 2016

    Swift and C have different memory models. This means that using Swift to call C functions in a manner that would be valid in C can cause memory safety problems. I'll show how this can occur with a subtle Release build bug inspired by issues that occurred while writing the previous article.
    Read more...
  • Partial functions in Swift, Part 2: Catching precondition failures

    Feb 2, 2016

    Partial functions are risky but if you're going to write one anyway, you should do something completely crazy to test that it is risky in all the right places.
    Read more...
  • Partial functions in Swift, Part 1: Avoidance

    Jan 25, 2016

    Partial functions (functions with preconditions) are a risky design choice. You probably have a few in your program, even if you haven't clearly identified them. Learn how to recognize them, learn about their risks, learn to avoid them and learn why you might choose to use them anyway.
    Read more...
  • A new era for Cocoa with Love

    Jan 25, 2016

    I'm drawing a line between the old Objective-C era posts on Cocoa with Love and the Swift era posts. The aim of the new era will be to make app programming suck less through a broad theme: "maintainable Cocoa apps". If we program with fewer runtime errors and new features are easier to add, we'll have more fun – even if "maintainable" sounds like a dull word.
    Read more...
  • Swift era

    Objective-C era

  • A big weakness in Objective-C's weak typing

    Jun 30, 2011

    We generally assume that we can send any message we want to a variable in our code typed as "id" and Objective-C's dynamic message handling will make the invocation work correctly at runtime. In some rare cases, this assumption is wrong. I'll look at situations where you need to be careful about sending messages to "id" typed variables and a situation where a limitation in the Objective-C language requires a hideous workaround to avoid serious bugs.
    Read more...
  • An RSS-feed and location-based iOS application

    Jun 20, 2011

    The purpose of this post is so that I will have a link to give people when they ask: how do I write an iOS application that pulls data from an RSS feed, displays it pretty and can put things on a map. I'll show you all of that and more as I rewrite my oldest iOS application from scratch: FuelView.
    Read more...
  • Classes for fetching and parsing XML or JSON via HTTP

    May 30, 2011

    In this post I show two reusable classes for fetching data via HTTP: one that parses the result as XML and another that parses as JSON. These are relatively simple tasks but due to the number of required steps, they can become tiresome if you don't have robust, reusable code for the task. These classes will work on iOS or on the Mac but the optional error alerts and password dialogs are only implemented for iOS.
    Read more...
  • Presenting a Mac dialog sheet with visual cue effects

    May 5, 2011

    In this post, I'll show you how to use visual effects over a window to make a dialog sheet stand out when it is presented over the top. It's a pretty simple use of Core Image but is a useful technique to capture attention when needed.
    Read more...
  • Background audio through an iOS movie player

    Apr 20, 2011

    Background audio in iOS is supposed to be as simple as entering a setting in your Info.plist and making sure your kAudioSessionProperty_AudioCategory is appropriate. This is true unless your audio is part of a movie file or is played in a movie player that has just played video — suddenly it becomes fiddly, hard to test, unreliable and changeable from version to version of iOS.
    Read more...
← Newer 1 2 3 4 5 6 7 8 9 10 Older →
  • Subscribe: RSS feed or Apple News
  • Twitter: cocoawithlove
  • Github: mattgallagher

© 2008-2016 Matt Gallagher. All rights reserved.
Code may be used in accordance with license on About page.
If Twitter and Github aren't working: ococ@ofniawithlove.com