Archives by date

You are browsing the site archives by date.

Managing Multiple Singleton Classes in Objective-C

There are already numerous articles describing different approaches to using singletons in Objective-C. All aproaches have their upsides and downsides, and I won’t get into that discussion here. Here’s what I wanted from my singleton implementation: It has to be in one class, which every class wanting to be a singleton must subclass, and by […]

Testing Asynchronous Code With GHUnit

If you’ve ever done a single unit test run on iOS, you know that Apple’s out-of-the-box unit testing sucks. It’s done at build time, instead of runtime, so there’s no way of debugging your test code. Also, if an exception is thrown at any point in your test code, the testing framework crashes with no […]


I’ve recently started a project on Github called UnREST. It’s a simple Cocoa Touch library for accessing RESTful web resources through an intuitive code interface. I’m aiming to add some more functionality over time (I’m using REST a lot at work), so if you have some cool ideas or feel like hacking, go for it. […]

Core Data BLOB Management with Virtual Properties

Keeping BLOBs (Binary Large OBjects) in your Core Data store is generally a bad idea. If you happen to have a large graph of managed objects in your application, it becomes increasingly difficult to manage memory. Faulting can help to a certain extent, but I’ve found it very difficult to successfully manage memory by faulting […]

Resizing UIImage objects

If you need a quick way to resize your UIImage objects project-wide, the best way to do so is to add a new method to the UIImage class by defining a category. Categories are Objective-C’s mechanism for extending a class’ functionality without subclassing it. So, let’s declare a new category named Resizing on UIImage, and […]

Populating The Core Data Store With Predefined Data

In my previous article, I’ve shown you a way to turn your managed objects into a dictionary, and vice-versa. In this article, we’ll use that code to populate the Core Data store with data stored in plain-text files in your project’s bundle. We’ll use JSON for representing our objects, but you can generally use any […]

Serializing (Archiving/Unarchiving) an NSManagedObject Graph

Since the NSManagedObject class doesn’t conform to the NSCopying protocol, there seems to be no easy way to archive a bunch of interrelated managed objects. Once you archive a part of your object graph, you could use the serialized representation for various purposes – sending it over a network, making backups, etc. The way I […]