For a new project I needed to emulate dial-up speeds while loading static content into a UIWebView. Unfortunately that class doesn’t provide any hooks to get into the read/write stream. Climbing down the stack doesn’t yield any help either. It so happens that I wanted this content to be local so embedding a web server into the app seemed like a good place to start. It turns out, GCDWebServer has exactly the hooks I needed. After a tip from the developers, I created a subclass of their GCDWebConnection class and overrode the read/write methods to sleep the threads for long enough to simulate a slow connection. I’ve posted the code as a gist.

Emulating a slow web server in iOS