Skip to content
A portable exposure therapy game.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A portable exposure therapy game.

What we're going for

Table of Contents

  1. A note on concurrency
  2. Documentation
  3. Vocabulary

A note on concurrency

Understanding concurrency in Swift is a big part of understanding this project. It took me a bit to get it, but you're probably smarter than me so you'll probably pick it up fast. Either way, here's an overview of everything you need to know.

Grand Central Dispatch

Want something to run on a different process in Swift? You need the GCD. The GCD provides you will multiple different process queues that handle everything for you.

The best way to think about GCD is like a list of jobs that you're adding to.

We use a cocoapod called GCDKit. GCDKit doesn't add any extra functionality, but it makes the entire process easier via syntactic sugar. It's a cleaner any prettier way to interact with the GCD.

Serial Queues

In Serial queues, processes happen one after the other.

Serial Queue

Concurrent Queues

In Concurrent queues, processes can happen at the same time.

Concurrent Queue

.async calls

A .async() call means the process returns immediately.

For example:

var wasHit = false

myGCD.async() {
  wasHit = true


Will print out false.

.sync calls

A .sync() call means the process returns when it's finished.

For example:

var wasHit = false

myGCD.sync() {
  wasHit = true


Will print out true.


Good documentation means we know what modules are available and are more likely to use them. Docs allow us to write less code.

Gif Buffer

Behold the great doodle that started it all:

Magic Image of drawing


The Gif Buffer is made up of two pieces, each running on their own processes. The first one is called the GiphyManager and the second one is called the ImageManager.

The basic flow is the following:

  • The GiphyManager collects URLs (and other stuff) from Giphy.
  • The GiphyManager enqueues those URLs into a queue data structure.
  • The ImageManager dequeues from the queue and collects the image data from them.
  • The ImageManager then enqueues them into another queue that stores all the gifs on the device.
  • The Main UI listens for the end of the current gif in the stream and then pulls from the image queue when it's at the end.

YET these processes are are all happening AT THE SAME TIME.


The GiphyManager's job is to collect and return Gif objects.

Inside, there's a requestQueue of GiphyRequests which gets populated before anything happens. Each GiphyRequest is an object that contains the offset and limit to be used in each Giphy request. More info on Giphy's request system here.


  • managerGCD | serial | Manages the GiphyManager
  • requestGCD | serial | Controls the requestQueue
  • responseGCD | serial | Controls the responseQueue


The ImageManager's job is to pull Gif objects from the GiphyManger's responseQueue. If it succeeds in doing this, it goes to the url and collects image data. Then it creates a GifImage which is an object that contains a UIView and a Gif.


  • managerGCD | concurrent | Manages the ImageManager
  • imageGCD | serial | Controls the image Queue


Handles the communication with the search endpoint in giphy.

ping - Gets the pagination data from the search query.

search - Actually performs a real search.


Handles going to the url and collecting the data there.

findImage - Goes to the URL, creates a GifImage and returns it.


I have a bunch of bullshitty words that I've been using to describe parts of the site. One of the things I've disliked when working on other projects is I never knew what any of the lingo meant. So this is basically a dictionary.

Gif Stream or Stream

This is the part of the app where the user can hold down and see an endless stream of gifs.


The gif buffer is the part of the project that loads in URL's from Giphy and then goes to each one of those urls and downloads the image.


GCD stands for Grand Central Dispatch and I hate typing that out all the time. It's synonymous with process and in general usage thread.

** In code, it specifically refers to a GCD Queue. ** However, it's super important you don't actually call it just a queue. We also use a Queue data structure and it gets REAL CONFUSING REAL FAST GUYS OKAY.

Resource Queue

In our concurrency model, the resource queue is for passing data between one module and another.

Game Over

The screen after the gif stream where the user goes to see their score and have the option of sharing their score with other folks in the internets.

You can’t perform that action at this time.