About Search Archive
Matt Gallagher: Cocoa with Love Matt Gallagher: Cocoa with Love
← Newer 4 5 6 7 8 9 10 11 12 Older →
  • Substituting local data for remote UIWebView requests

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

    In this post, I'll show you how you can load a webpage in a UIWebView in iOS while using a modified NSURLCache to substitute local copies of resources within the webpage for the remote copies referred to by the actual page.
    Read more...
  • Alternative Objective-C object allocation for large arrays

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

    In this post, I'll show you how you can create objects without using the standard instance allocation process (either +[NSObject alloc] or class_createInstance()). I'll also explain why you might do this — the benefits and drawbacks to a custom object creation process.
    Read more...
  • Is a virtual machine for Cocoa programming inevitable?

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

    Recent articles by Jesper have re-ignited some discussion about whether Apple might be working on another programming language to replace Objective-C. Neither of these articles closely examined a related but possibly more important question: is Apple planning to move application development to a virtual machine? In this article, I'll look at why I think moving to a virtual machine might happen along with a possible language transition.
    Read more...
  • 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...
← Newer 4 5 6 7 8 9 10 11 12 Older →
  • Subscribe: RSS or JSON
  • Mastodon: @cocoawithlove
  • Bluesky: @cocoawithlove
  • Github: mattgallagher

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