Matt Gallagher: Cocoa with Love

Articles about Swift, Cocoa, software design and programming.

  • May 15, 2008

    Objective-C era

    Objective-C 2.0: Fast enumeration clarifications

    Fast enumeration in Objective-C 2.0 is a doubly useful addition: it results in code that looks better and runs faster. Its documentation though, still contains a few points which are ambiguous or misleading. Here are some clarifications that I've uncovered.

    Read article

  • May 9, 2008

    Objective-C era

    Square Root: Numerical fun with NSDecimalNumber

    NSDecimalNumber is a powerful Foundation class that holds high precision base 10 numbers. The default class only provides basic arithmetic operators, leaving you to write any advanced operations that you need. This is an example that implements a square root using NSDecimalNumber.

    Read article

  • Apr 20, 2008

    Objective-C era

    viewWillDraw - a welcome addition to NSView in 10.5

    A method named viewWillDraw appeared in NSView in Mac OS X 10.5. If you have cause to use it, this method replaces 6 other methods from earlier versions of Mac OS X. Read more to find out if you should use it and how it helps.

    Read article

  • Apr 14, 2008

    Objective-C era

    Type punning isn't funny: Using pointers to recast in C is bad.

    A very common C technique for reinterpreting data types has the potential to cause nasty bugs. Apple knows this, which is why the implementation of NSRectToCGRect (correctly) doesn't do what the documention claims. I show you a technique to perform reinterpret casts safely in your own code.

    Read article

  • Apr 6, 2008

    Objective-C era

    The value of immutable values

    This is an explanation of why Cocoa contains immutable value classes and why the value classes you create in your own program should be immutable too.

    Read article

  • Mar 30, 2008

    Objective-C era

    Supersequent implementation

    Ever wanted to override a method using a category but still invoke the default method from the category? Like invoking the super method on a super class, this example will show you how to invoke any "supersequent" method no matter if its on the super class, the current class or even another category on the current class.

    Read article