AFNetworking/AFNetworking — pull request #309 by kirsplatrick (2012-04-19 23:09:16+00:00)
Title: Removed unneeded and possibly unsafe dispatch_once in setCompletionBlock

It looks as though `dispatch_once_t` must be defined globally or the results of calling `dispatch_once` will be undefined. Thanks to @cahn for pointing this out in #288. The problem is I must define the `dispatch_once_t` predicate locally to allow each object to call `dispatch_group_leave` once per object.

After thinking about it for a bit, I realized that `dispatch_once` is really overkill for this situation (I was getting very dispatch happy) . The completion block is always run on a single thread and so any subsequent calls to `dispatch_group_leave` will be called serially. So I have amended this to use a simple `BOOL` flag.

I am not sure as to why problems have not arisen from the use of `dispatch_once` in the current implementation, but it looks as though apple advises against it and we should go ahead and correct it.