top
about archive search zqueue.com
Matt Gallagher: Cocoa with Love Matt Gallagher: Cocoa with Love
← Newer 4 5 6 7 8 9 10 11 12 Older →
  • Tips & Tricks for conditional iOS3, iOS3.2 and iOS4 code

    Jul 6, 2010 (an Objective-C era article)

    In this post, I'll show you ways to determine which version of iOS you are running on and show you how to write a macro that can both conditionally compile and runtime switch between the code for different versions of iOS.
    Read more...
  • Assign, retain, copy: pitfalls in Obj-C property accessors

    Jun 30, 2010 (an Objective-C era article)

    In this post, I'll look at some very subtle problems that can occur if a getter or setter method chooses the wrong memory management pattern and in the process, explain why NSDictionary copies its keys rather than simply retains them.
    Read more...
  • The design of every Mac application

    Jun 22, 2010 (an Objective-C era article)

    I was recently asked by a reader if I used any modelling program to model the classes and relationships in my Mac applications. The answer is no, I don't model the application side of my programs. The reason for this is not because applications are always small and simple. The reason is that all applications have approximately the same design — eventually everything in a well-designed application becomes intuitive.
    Read more...
  • Sorting an NSMutableArray with a random comparison method

    Jun 10, 2010 (an Objective-C era article)

    If you sorted an NSMutableArray with a comparison method that randomly returns either higher or lower, would the result be an even, random distribution? Spoiler: no it won't but the actual distribution is interesting nonetheless. I'll show you what would happen if you did sort this way (and also show you how to correctly randomize an array if you did want an even distribution).
    Read more...
  • Avoiding deadlocks and latency in libdispatch

    Jun 2, 2010 (an Objective-C era article)

    The system-wide thread pool of libdispatch's global queue is an easy way to efficiently manage concurrent operations but it is not the solution to all threading problems and it is not without its own class of problems. In this post I look at deadlocks and latency problems that are inherent in thread-pool based solutions like libdispatch's global concurrent queue so that you will know when you should use this option and when you need something else.
    Read more...
  • Handling unhandled exceptions and signals

    May 25, 2010 (an Objective-C era article)

    When an application crashes on the iPhone, it disappears without telling the user what happened. However, it is possible to add exception and signal handling to your applications so that an error message can be displayed to the user or you can save changes. It is even possible to try to recover from this situation without crashing at all.
    Read more...
  • 5 ways to draw a 2D shape with a hole in CoreGraphics

    May 17, 2010 (an Objective-C era article)

    In this post, I look at 5 different ways that you can draw a very simple shape: a square with a triangular hole cut out of the center. In a drawing environment like CoreGraphics which offers double buffering, winding count path filling, even-odd path filling and clipping regions, there's no single answer. An iPhone sample project is provided containing the code but all drawing functions are identical on the Mac.
    Read more...
  • A look at how malloc works on the Mac

    May 12, 2010 (an Objective-C era article)

    In this post, I'll take a high-level look at how malloc is implemented on the Mac. I'll look at how memory is allocated for "tiny", "small" and "large" allocation scales, the multi-core performance improvements introduced in Snow Leopard and some inbuilt debugging features you can trigger for finding memory problems including buffer overruns.
    Read more...
  • Finding or creating the application support directory

    May 6, 2010 (an Objective-C era article)

    A simple post this week but one which optimizes a common task: locating the application support directory for the current application, creating it if it doesn't exist. The result makes accessing the current application's support directory a single line and provides a structure for locating and creating folders at other standard locations with similar ease.
    Read more...
  • Porting a Mac program to Windows using The Cocotron

    Apr 27, 2010 (an Objective-C era article)

    In this last of three posts about porting a Mac application to Windows, I look at the steps involved in setting up The Cocotron with a remote debugging session between Xcode and the application running on Windows. I'll also talk about the code that didn't "just work" and some of the approaches I used to fix the program and get it working.
    Read more...
← Newer 4 5 6 7 8 9 10 11 12 Older →
  • Subscribe: RSS or JSON
  • Twitter: @cocoawithlove
  • Github: mattgallagher

© 2008-2021 Matt Gallagher. All rights reserved.
Code may be used in accordance with license on About page.
If you need to contact me: