LockBlocks 0.0.2

LockBlocks 0.0.2

LangLanguage Obj-CObjective C
License BSD
ReleasedLast Release Dec 2014

Maintained by Unclaimed.

  • By
  • Nate Petersen


LockBlocks adds block methods to Objective-C Lock objects. It also adds a Read/Write Lock class.


Instead of making a call like this:

[myLock lock];

... critical code ...

[myLock unlock];

With LockBlocks you use the block-based methods that call lock and unlock for you:

[myLock executeInLock:^{
    ... critical code ...

This more clearly delineates what is a critical section of your code, and helps avoid forgetting to release the lock.

LockBlocks also adds an Objective-C version of a Read/Write Lock (implemented using pthreads). This allows you to use exclusive/non-exclusive locks. Please read the important note about re-entrancy (recursion) in DRReadWriteLock.h.


I highly recommend that you use CocoaPods to integrate LockBlocks into your app. If you aren't familiar with it, CocoaPods is an awesomely simple dependency manager for Objective-C projects. You can get more info about it here.

If you're using CocoaPods, all you have to do is put this line in your Podfile:

pod 'LockBlocks',   '0.0.1'

And you're done.

If you aren't using CocoaPods (Why not? What's your problem??) then you'll have to just grab the LockBlocks source and drop it into your project.


LockBlocks version 0.0.1 is still a beta release. Some of the methods have not been thoroughly tested. Use at your own risk, and please file a bug if you encounter any problems.


If you end up using LockBlocks in a project, I'd love to hear about it.

email: [email protected]
twitter: @nate_petersen