Matt Gallagher: Cocoa with Love

Articles about Swift, Cocoa, software design and programming.

  • May 19, 2016

    Random number generators in Swift

    I present a few random number generators in Swift and investigate their quality versus performance. I also look at performance implementations and see if I can make a C algorithm run as fast as Swift.

    Swiftmathematics

    Read article

  • May 1, 2016

    Comparing Swift to C++ for parsing

    I present an implementation of Swift's Demangle.cpp, rewritten in Swift and use the two versions (the original C++ and my Swift version) to compare the C++ and Swift for writing parsers.

    Swiftparsing

    Read article

  • Apr 14, 2016

    Presenting unanticipated errors to users

    In my first truly 'Cocoa' article since restarting Cocoa with Love, I'll talk about presenting errors to the user. In particular, ensuring that errors we didn't expect or plan for are presented in a manner that allows error reporting by users and easier bug fixing.

    error handlingCocoa

    Read article

  • Mar 27, 2016

    Breaking Swift with reference counted structs

    Struct types are not usually heap allocated, reference counted or able to perform work on deallocation. You can coerce them into having these properties but careful if you do: it can be a source of memory leaks, errant behavior and compiler crashes.

    hacksSwift

    Read article

  • Mar 17, 2016

    Errors: unexpected, composite, non-pure, external.

    Error handling is a topic I plan to visit periodically but it's difficult since 'error' is such a poorly defined term. In this article, I give a clear definition of an error and further define the most common associated complications. The intent is to establish a foundation for future discussions on the topic.

    fundamentalserror handling

    Read article

  • Feb 28, 2016

    Tracking tasks with stack traces in Swift

    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.

    Swiftdebug analysis

    Read article

  • Feb 16, 2016

    Use it or lose it: why safe C is sometimes unsafe Swift

    Swift and C have different memory layouts. 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.

    Swift

    Read article