Objective-C Singleton Pattern Updated For Testability

Objective-C Singleton Pattern Updated For Testability

Posted by on Jan 24, 2013 in BDD, iOS, iPad, iPhone, Mac OS X, Software Development, TDD | 11 Comments

At Two Bit Labs we do a fair amount of unit testing. In places where we use singletons we use a variation on the the Objective-C dispatch_once pattern of thread safe singleton creation. This variation supports resetting the singleton or replacing it with a mock object. That way in our unit tests we can do […]

Adding Unit Tests to an existing iOS project with Xcode 4

When you build a new iPhone or iPad app from scratch, you can generate a new project with tests using Xcode’s project templates, and the test dependency is set up correctly. However, if you add a unit test target to an existing iOS project, there are some manual steps required to set up the target […]