7 Nov

Earlier this year I noticed something that had been bothering me for awhile. I had more than a few apps in the store; seven of my own, plus a couple for contracts. While no single one of them was taking a lot of time, the aggregate effect of them all left me drained and unable to support any of them as fully as they should be. Some didn’t even support the iPhone 5’s screen size (ouch). It was time to cut some weight.

I’m very fortunate in that my day job pays well for my area’s cost of living. Because of which I don’t have to rely on income from my apps. I looked at this as an opportunity to focus less on trying to make a profit and more on trying to hone my skills.

With that clearly in mind I decided it was time I focused on making the best versions possible of just two or three apps rather than spreading my time and attention across many.

Choosing to remove apps from the store and deciding which ones to keep, especially apps that don’t generate much money (0’Clock literally makes a couple of bucks a month), wasn’t an easy decision.

Ultimately I decided on keeping three:

  • Consumed – as my first iPhone game it’s near to my heart, and my friends and I still play it quite a bit.
  • 0’Clock – a binary clock I made while my wife was learning binary in college. She in turn bought me a real one for Xmas which sits on my desk at work. It requires little effort to do what it’s intended to do, so it’s a good app to cut my teeth on new technology, like Swift.
  • Fit to Fight – an Air Force physical training test calculator that, I’m proud to say, is used by thousands of United States Airmen worldwide.

Just because you can build something, doesn’t mean you should. I’m learning this the hard way. But I’m very optimistic about the future of these apps and what I will learn.

Dispatching your work

2 Nov

Grand Central Dispatch is an awesome technology. There is a ton of stuff in GCD we could talk about, but I’m going to pick one specific part to talk about today.

Dispatch Groups. Apple defines dispatch groups as “a way to monitor a set of block objects for completion. (You can monitor the blocks synchronously or asynchronously depending on your needs.) Groups provide a useful synchronization mechanism for code that depends on the completion of other tasks.”

But what does that really mean to you? Well say for example you want to run some tasks on a background thread and then execute some code when all the background tasks have finished. You could try and use flags to track the state of all the tasks or maybe setup a counter system to track their status and then execute your completion code when all the tasks have finished. But wait, smell that? That’s code smell. You know there’s a better way, and your right. Your so smart.

Dispatch groups provide a convenient way of tracking tasks and can notify you when the tasks have been completed. A dispatch group keeps a counter of active tasks and when the count drops to zero it can call a designated block.

Heres a quick example.

// Create a dispatch group
dispatch_group_t group = dispatch_group_create();

// cycle through dispatching some background tasks
for(int i = 0; i < 10; i++)
	// increment the group's task counter
	// start a background task
		// do some work on a background thread
		// decrement the group's task counter

// set a block for the dispatch group to call when the group's counter gets to zero
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
	// all our tasks have finished