I’ve just submitted new versions of both of my apps on the App Store. Pin Your Pics had a bug in the ‘group by 50’ table, which meant that the cells comprising the sets of images was empty. I actually need to do a pretty major overhaul of the code base, as I learned a lot about threading in the process of updating WeighMe with the motion activity functionality. I finally got the async functionality [which I posted an update on a few weeks ago] working. I didn’t change the algorithm that I discussed in the post that substantially, however testing indicated that putting counters in the KVO wasn’t reliable. The KVO still checks to see if the queue is at zero. What I simply did was to shift the ‘gatekeeper’ functionality into the method call which executes the plot.
The queue might be empty at the point in time the KVO executes, but that doesn’t mean that there isn’t more activity is in the pipe for the operation queue. As a consequence, in earlier versions of this code I was seeing my plotting method getting called repeatedly. On entry to the plotting method – which is going to be called every time the queue hits zero – I check for two values: the length of an array, which gets appended to by assignment to the operation queue, and also a boolean, which effectively ensures that the method is only ever executed once, when the array has the right number of values.